Previous topic


Next topic


This Page


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


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@"
my_database = DatabaseInterface(dsn)
# then connect
await my_database.connect()
Parameters:dsn (str) – The Data Source Name <>_ to connect to the database on.
dialect = None

The current Dialect instance.

connector = None

The current connector instance.


Checks if this DB is connected.


Binds tables to this DB instance.


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.

Gets a low-level BaseTransaction.

async with db.get_transaction() as transaction:
    results = await transaction.cursor("SELECT 1;")
Return type:BaseTransaction

Gets a new Session bound to this instance.

Return type:Session

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.


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