API Reference¶
Connect¶
-
aql.
connect
(location: Union[str, aql.types.Location], *args: Any, **kwargs: Any) → aql.engines.base.Connection¶ Connect to the specified database.
Tables¶
-
class
aql.column.
Column
(name: str, ctype: Type = None, default: Any = <object object>, table_name: str = '')¶ Bases:
object
-
in_
(values: Sequence[Any]) → aql.types.Comparison¶
-
property
full_name
¶
-
-
class
aql.table.
Table
(name: str, cons: Iterable[Union[aql.column.Column, aql.column.Index]], source: Type[T] = None)¶ Bases:
typing.Generic
Table specification using custom columns and a source type.
-
delete
() → aql.query.Query¶ Shortcut for Query(<table>).delete()
-
insert
(*columns: aql.column.Column) → aql.query.Query¶ Shortcut for Query(<table>).insert()
-
select
(*columns: aql.column.Column) → aql.query.Query¶ Shortcut for Query(<table>).select()
-
update
(*comps: aql.types.Comparison, **values: Any) → aql.query.Query¶ Shortcut for Query(<table>).update()
-
Errors¶
-
exception
aql.
BuildError
¶ Bases:
aql.errors.AqlError
-
exception
aql.
QueryError
¶ Bases:
aql.errors.AqlError
Advanced¶
-
class
aql.engines.base.
Engine
¶ Bases:
object
-
prepare
(query: aql.query.Query[~ T][T]) → aql.query.PreparedQuery[~T][T]¶ 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.
-
-
class
aql.engines.base.
Connection
(engine: aql.engines.base.Engine, location: aql.types.Location, *args: Any, **kwargs: Any)¶ Bases:
object
-
async
cursor
() → aql.engines.base.Cursor¶ Return a new cursor object.
-
execute
(query: aql.query.Query[~ T][T]) → aql.engines.base.Result[~T][T]¶ Execute the given query on a new cursor and return the cursor.
-
classmethod
get_connector
(name: str) → Tuple[Type[aql.engines.base.Connection], Type[aql.engines.base.Engine]]¶ Given a name, get a connector class.
-
query
(query: aql.query.Query[~ T][T]) → aql.engines.base.Result[~T][T]¶ Execute the given query on a new cursor and return the cursor.
-
property
autocommit
¶
-
async
-
class
aql.engines.base.
Cursor
(connection: aql.engines.base.Connection, cursor: Any)¶ Bases:
object
-
convert
(row) → T¶ Convert from the cursor’s native data type to the query object type.
-
async
fetchall
() → Sequence[Any]¶ Return all rows from the previous query.
-
async
fetchone
() → Optional[Any]¶ Return the next row from the previous query, or None when exhausted.
-
property
connection
¶ Return the associated connection object.
-
property
last_id
¶ ID of last modified row, or None if not available.
-
property
row_count
¶ Number of rows affected by previous query.
-
-
class
aql.engines.base.
Result
(query: aql.query.Query[~ T][T], connection: aql.engines.base.Connection)¶ Bases:
typing.Generic
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())
-
async
row
() → Optional[T]¶
-
async
rows
() → Sequence[T]¶
-
async
run
() → aql.engines.base.Cursor¶
-
property
last_id
¶ ID of last modified row, or None if not available.
-
property
row_count
¶ Number of rows affected by previous query.
-
async