All public methods included in the module. See the Examples pages for some usage examples.
The BlockingClient class is a wrapper around the psycopg2 module and provides some extra functionality.
Parameters: | settings – A dictionary that is passed to the BlockingPool object. |
---|
Create a context for a connection and commit changes on exit.
For example:
with self.db.connection() as conn:
cursor = conn.cursor()
cursor.execute('SELECT 42, 12, 40, 11;')
Parameters: | settings – A dictionary that is passed to the AsyncPool object. |
---|
Run a batch of queries all at once.
Note: Every query needs a free connection. So if three queries are are executed, three free connections are used.
A dictionary with queries looks like this:
{
'query1': ['SELECT 42, 12, %s, %s;', (23, 56)],
'query2': 'SELECT 1, 2, 3, 4, 5;',
'query3': 'SELECT 465767, 4567, 3454;'
}
A query with paramaters is contained in a list: ['some sql here %s, %s', ('and some', 'paramaters here')]. A query without paramaters doesn’t need to be in a list.
Parameters: |
|
---|---|
Returns: | A dictionary with the same keys as the given queries with the resulting cursors as values. |
Call a stored database procedure with the given name.
The sequence of parameters must contain one entry for each argument that the procedure expects. The result of the call is returned as modified copy of the input sequence. Input parameters are left untouched, output and input/output parameters replaced with possibly new values.
The procedure may also provide a result set as output. This must then be made available through the standard fetch*() methods.
Parameters: |
|
---|
Run a chain of queries in the given order.
A list/tuple with queries looks like this:
(
['SELECT 42, 12, %s, 11;', (23,)],
'SELECT 1, 2, 3, 4, 5;'
)
A query with paramaters is contained in a list: ['some sql here %s, %s', ('and some', 'paramaters here')]. A query without paramaters doesn’t need to be in a list.
Parameters: |
|
---|---|
Returns: | A list with the resulting cursors. |
Close all connections in the connection pool.
Prepare and execute a database operation (query or command).
Parameters may be provided as sequence or mapping and will be bound to variables in the operation. Variables are specified either with positional (%s) or named (%(name)s) placeholders. See Passing parameters to SQL queries [1] in the Psycopg2 documentation.
Parameters: |
|
---|
A connection pool that manages blocking PostgreSQL connections and cursors.
Parameters: |
|
---|
Close all open connections in the pool.
Get a connection from the pool.
If there’s no free connection available, a new connection will be created.
A connection pool that manages asynchronous PostgreSQL connections and cursors.
Parameters: |
|
---|
Close all open connections in the pool.
Create a new cursor.
If there’s no connection available, a new connection will be created and new_cursor will be called again after the connection has been made.
Parameters: |
|
---|
An asynchronous connection object.
Parameters: | ioloop – An instance of Tornado’s IOLoop. |
---|
Close connection.
Read-only attribute reporting whether the database connection is open (0) or closed (1).
Get a cursor and execute the requested function
Parameters: |
|
---|
Return True if the connection is executing an asynchronous operation.
Open the connection to the database,
Parameters: |
|
---|
Run a chain of queries in the given order.
A list/tuple with queries looks like this:
(
['SELECT 42, 12, %s, 11;', (23,)],
'SELECT 1, 2, 3, 4, 5;'
)
A query with paramaters is contained in a list: ['some sql here %s, %s', ('and some', 'paramaters here')]. A query without paramaters doesn’t need to be in a list.
Parameters: |
|
---|---|
Returns: | A list with the resulting cursors is passed on to the callback. |
Run a batch of queries all at once.
Note: Every query needs a free connection. So if three queries are are executed, three free connections are used.
A dictionary with queries looks like this:
{
'query1': ['SELECT 42, 12, %s, %s;', (23, 56)],
'query2': 'SELECT 1, 2, 3, 4, 5;',
'query3': 'SELECT 465767, 4567, 3454;'
}
A query with paramaters is contained in a list: ['some sql here %s, %s', ('and some', 'paramaters here')]. A query without paramaters doesn’t need to be in a list.
Parameters: |
|
---|---|
Returns: | A dictionary with the same keys as the given queries with the resulting cursors as values is passed on to the callback. |