10.5. Module db¶
The cerebro.db module provides access to remote database for SQL queries execution.
Classes
-
class
cerebro.db.
Db
(db_timeout=5, db_reconn_count=3)[source]¶ The class of access to remote Cerebro database.
Methods
You can work with Cerebro database directly, executing SQL read/write queries.
The access to the data is provided by means of procedures stored on the database side. See more detailed info on the procedures in the Memoria database SQL API chapter.
db = cerebro.db.Db() res = db.execute('select "listProjects_01"(%s,%s)', false, true) # executing a query to get a list of projects print('The list of projects', res) # printing the result
-
execute
(query, *parameters)[source]¶ Parameters: - query (string) – SQL query string.
- parameters – query parameters.
Returns: query result.
Return type: Executes the query and returns the result as a list of tuples.
The query arguments have the format %s.
db = cerebro.db.Db() projects = db.execute('select "listProjects_01"(%s,%s)', false, true) # executing a query to get a list of projects print('Список проектов', projects) # printing the result
db = cerebro.db.Db() # executing a query to set task progress to 50% projects = db.execute('select "taskSetProgress_a"(%s,%s)', {task_id,}, 50)
-