API Reference¶
Connect¶
- aql.connect(location, *args, **kwargs)¶
Connect to the specified database.
- Parameters:
- Return type:
Tables¶
- class aql.table.Table(name, cons, source=None)¶
Bases:
Generic
[T
]Table specification using custom columns and a source type.
- create(if_not_exists=False)¶
Shortcut for Query(<table>).create()
- Parameters:
if_not_exists (bool)
- Return type:
Query
- delete()¶
Shortcut for Query(<table>).delete()
- Return type:
Query
- insert(*columns)¶
Shortcut for Query(<table>).insert()
- Parameters:
columns (Column)
- Return type:
Query
Errors¶
Advanced¶
- class aql.engines.base.Engine¶
Bases:
object
- prepare(query)¶
Given a query, generate the full SQL query and all parameters.
Default behavior is to call the method on the engine class corresponding to the query action.
- Parameters:
query (Query[T])
- Return type:
PreparedQuery[T]
- class aql.engines.base.Connection(engine, location, *args, **kwargs)¶
Bases:
object
- async abort()¶
Rollback/cancel the current transaction.
- Return type:
None
- async begin()¶
Begin a new transaction.
- Return type:
None
- async close()¶
Close the connection.
- Return type:
None
- async commit()¶
Commit the current transaction.
- Return type:
None
- async connect()¶
Initiate the connection.
- Return type:
None
- execute(query)¶
Execute the given query on a new cursor and return the cursor.
- Parameters:
query (Query[T])
- Return type:
Result[T]
- classmethod get_connector(name)¶
Given a name, get a connector class.
- query(query)¶
Execute the given query on a new cursor and return the cursor.
- Parameters:
query (Query[T])
- Return type:
Result[T]
- async rollback()¶
Rollback/cancel the current transaction.
- Return type:
None
- class aql.engines.base.Cursor(connection, cursor)¶
Bases:
object
- Parameters:
connection (Connection)
cursor (Any)
- async close()¶
Close the cursor.
- Return type:
None
- convert(row)¶
Convert from the cursor’s native data type to the query object type.
- Return type:
T
- async execute(query, parameters=None)¶
Execute the given query with this cursor.
- async fetchone()¶
Return the next row from the previous query, or None when exhausted.
- Return type:
Any | None
- async query(query, parameters=None)¶
Execute the given query with this cursor.
- property connection: Connection¶
Return the associated connection object.
- class aql.engines.base.Result(query, connection)¶
Bases:
Generic
[T
]Lazy awaitable or async-iterable object that runs the query once awaited.
Awaiting the result object will fetch and convert all rows to appropriate objects. Iterating the result will fetch and convert individual rows at a time.
Examples:
result = db.execute(Foo.select()) # query not yet executed rows = await result # query executed and any resulting rows returned print(result.row_count) async for row in db.execute(Foo.select()): ... rows = await db.execute(Foo.select())
- Parameters:
query (Query[T])
connection (Connection)
- async row()¶
- Return type:
T | None