The main Database object. This is the “database interface” to the actual DB server.
Classes
DatabaseInterface (dsn[, connector]) |
The “database interface” to your database. |
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.
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_ddl_session
(**kwargs)[source]¶Gets a new DDLSession
bound to this instance.
Return type: | DDLSession |
---|