Previous topic

asyncqlio

Next topic

asyncqlio.orm

This Page

asyncqlio.db

The main Database object. This is the “database interface” to the actual DB server.

Classes

DatabaseInterface(dsn[, connector]) The “database interface” to your database.
class asyncqlio.db.DatabaseInterface(dsn, connector=None)[source]

Bases: object

The “database interface” to your database. This provides the actual connection to the DB server, including things such as querying, inserting, updating, et cetera.

Creating a new database object is simple:

# pass the DSN in the constructor
dsn = "postgresql://postgres:B07_L1v3s_M4tt3r_T00@127.0.0.1/mydb"
my_database = DatabaseInterface(dsn)
# then connect
await my_database.connect()
Parameters:dsn (str) – The Data Source Name <http://whatis.techtarget.com/definition/data-source-name-DSN>_ to connect to the database on.
dialect = None

The current Dialect instance.

connector = None

The current connector instance.

connected

Checks if this DB is connected.

bind_tables(md)[source]

Binds tables to this DB instance.

emit_param(name=None)[source]

Emits a param in the format that the DB driver specifies.

Parameters:name (Optional[str]) – The name to use. If this is None, a name will automatically be used, and no name param will be returned.
Return type:Union[Tuple[str, str], str]
Returns:The emitted param, and the name of the param emitted.
get_transaction(**kwargs)[source]

Gets a low-level BaseTransaction.

async with db.get_transaction() as transaction:
    results = await transaction.cursor("SELECT 1;")
Return type:BaseTransaction
get_session(**kwargs)[source]

Gets a new Session bound to this instance.

Return type:Session
get_ddl_session(**kwargs)[source]

Gets a new DDLSession bound to this instance.

Return type:DDLSession
coroutine close()[source]

Closes the current database interface.

coroutine connect(self, **kwargs)[source]

Connects the interface to the database server.

Note

For SQLite3 connections, this will just open the database for reading.

Return type:BaseConnector
Returns:The BaseConnector established.
coroutine get_db_server_version(self)[source]

Gets the version of the DB server.

Return type:str