The asyncpg connector for PostgreSQL databases.
Functions
get_param_query (sql, params) |
Re-does a SQL query so that it uses asyncpg’s special query format. |
Classes
AsyncpgConnector (parsed) |
A connector that uses the asyncpg library. |
AsyncpgResultSet (cur) |
|
AsyncpgTransaction (conn) |
A transaction that uses the asyncpg library. |
CONNECTOR_TYPE |
alias of asyncqlio.backends.postgresql.asyncpg.AsyncpgConnector |
asyncqlio.backends.postgresql.asyncpg.
get_param_query
(sql, params)[source]¶Re-does a SQL query so that it uses asyncpg’s special query format.
Parameters: | |
---|---|
Return type: | |
Returns: | A two-item tuple of (new_query, arguments) |
asyncqlio.backends.postgresql.asyncpg.
AsyncpgResultSet
(cur)[source]¶Bases: asyncqlio.backends.base.BaseResultSet
fetch_many
(self, n)[source]¶Fetches the next N rows in this query.
Parameters: | n (int ) – The number of rows to fetch. |
---|
asyncqlio.backends.postgresql.asyncpg.
AsyncpgTransaction
(conn)[source]¶Bases: asyncqlio.backends.base.BaseTransaction
A transaction that uses the asyncpg library.
acquired_connection
= None¶The acquired connection from the connection pool.
transaction
= None¶The asyncpg internal transaction.
close
(self, *, has_error=False)[source]¶Called at the end of a transaction to cleanup. The connection will be released if there’s no error; otherwise it will be closed.
Parameters: | has_error (bool ) – If the transaction has an error. |
---|
create_savepoint
(self, name)[source]¶Creates a savepoint in the current transaction.
Warning
This is not supported in all DB engines. If so, this will raise
NotImplementedError
.
Parameters: | name (str ) – The name of the savepoint to create. |
---|
cursor
(self, sql, params=None)[source]¶Executes a SQL statement and returns a cursor to iterate over the rows of the result.
Return type: | AsyncpgResultSet |
---|
asyncqlio.backends.postgresql.asyncpg.
AsyncpgConnector
(parsed)[source]¶Bases: asyncqlio.backends.base.BaseConnector
A connector that uses the asyncpg library.
pool
= None¶The asyncpg.pool.Pool
connection pool.
emit_param
(name)[source]¶Emits a parameter that can be used as a substitute during a query.
Parameters: | name (str ) – The name of the parameter. |
---|---|
Return type: | str |
Returns: | A string that represents the substitute to be placed in the query. |
get_transaction
()[source]¶Gets a new transaction object for this connection.
Return type: | AsyncpgTransaction |
---|---|
Returns: | A new BaseTransaction object attached to this connection. |
asyncqlio.backends.postgresql.asyncpg.
CONNECTOR_TYPE
¶alias of asyncqlio.backends.postgresql.asyncpg.AsyncpgConnector