aiosql.adapters package

Submodules

aiosql.adapters.aiosqlite module

class aiosql.adapters.aiosqlite.AioSQLiteAdapter

Bases: object

async execute_script(conn, sql)
async insert_returning(conn, _query_name, sql, parameters)
async insert_update_delete(conn, _query_name, sql, parameters)
async insert_update_delete_many(conn, _query_name, sql, parameters)
is_aio_driver = True
process_sql(_query_name, _op_type, sql)

Pass through function because the aiosqlite driver can already handle the :var_name format used by aiosql and doesn’t need any additional processing.

Args:

  • _query_name (str): The name of the sql query.

  • _op_type (SQLOperationType): The type of SQL operation performed by the query.

  • sql (str): The sql as written before processing.

Returns:

  • str: Original SQL text unchanged.

async select(conn, _query_name, sql, parameters, record_class=None)
select_cursor(conn, _query_name, sql, parameters)
async select_one(conn, _query_name, sql, parameters, record_class=None)
async select_value(conn, _query_name, sql, parameters)

aiosql.adapters.asyncpg module

class aiosql.adapters.asyncpg.AsyncPGAdapter

Bases: object

async execute_script(conn, sql)
async insert_returning(conn, query_name, sql, parameters)
async insert_update_delete(conn, query_name, sql, parameters)
async insert_update_delete_many(conn, query_name, sql, parameters)
is_aio_driver = True
maybe_order_params(query_name, parameters)
process_sql(query_name, _op_type, sql)

asyncpg seems to only support numeric.

async select(conn, query_name, sql, parameters, record_class=None)
select_cursor(conn, query_name, sql, parameters)
async select_one(conn, query_name, sql, parameters, record_class=None)
async select_value(conn, query_name, sql, parameters)
class aiosql.adapters.asyncpg.MaybeAcquire(client, driver=None)

Bases: object

aiosql.adapters.duckdb module

class aiosql.adapters.duckdb.DuckDBAdapter(*args, cursor_as_dict: bool = False, use_cursor: bool = True, **kwargs)

Bases: GenericAdapter

DuckDB Adapter

insert_returning(conn, query_name, sql, parameters)

Special case for RETURNING (<! suffix) with SQLite.

process_sql(query_name, op_type, sql)

Pass-through SQL query preprocessing.

select(conn, query_name: str, sql: str, parameters, record_class=None)

Handle a relation-returning SELECT (no suffix).

select_one(conn, query_name, sql, parameters, record_class=None)

Handle a tuple-returning (one row) SELECT (^ suffix).

Return None if empty.

aiosql.adapters.generic module

class aiosql.adapters.generic.GenericAdapter(*args, **kwargs)

Bases: SyncDriverAdapterProtocol

Generic AioSQL Adapter suitable for named parameter style and no with support.

This class also serves as the base class for other adapters.

Miscellaneous parameters are passed to cursor creation.

execute_script(conn, sql)

Handle an SQL script (# suffix).

insert_returning(conn, query_name, sql, parameters)

Special case for RETURNING (<! suffix) with SQLite.

insert_update_delete(conn, query_name, sql, parameters)

Handle affected row counts (INSERT UPDATE DELETE) (! suffix).

insert_update_delete_many(conn, query_name, sql, parameters)

Handle affected row counts (INSERT UPDATE DELETE) (*! suffix).

process_sql(query_name, op_type, sql)

Pass-through SQL query preprocessing.

select(conn, query_name: str, sql: str, parameters, record_class=None)

Handle a relation-returning SELECT (no suffix).

select_cursor(conn, query_name, sql, parameters)

Return the raw cursor after a SELECT exec.

select_one(conn, query_name, sql, parameters, record_class=None)

Handle a tuple-returning (one row) SELECT (^ suffix).

Return None if empty.

select_value(conn, query_name, sql, parameters)

Handle a scalar-returning (one value) SELECT ($ suffix).

Return None if empty.

aiosql.adapters.mysql module

class aiosql.adapters.mysql.BrokenMySQLAdapter(*args, **kwargs)

Bases: PyFormatAdapter

Work around PyMySQL and MySQLDB mishandling of empty parameters and lack of willingness to fix the issue.

See: https://github.com/PyMySQL/PyMySQL/issues/1059

insert_returning(conn, query_name, sql, parameters: Dict | List | None)

Special case for RETURNING (<! suffix) with SQLite.

insert_update_delete(conn, query_name, sql, parameters: Dict | List | None)

Handle affected row counts (INSERT UPDATE DELETE) (! suffix).

select(conn, query_name, sql, parameters: Dict | List | None, record_class=None)

Handle a relation-returning SELECT (no suffix).

select_one(conn, query_name, sql, parameters: Dict | List | None, record_class=None)

Handle a tuple-returning (one row) SELECT (^ suffix).

Return None if empty.

select_value(conn, query_name, sql, parameters: Dict | List | None)

Handle a scalar-returning (one value) SELECT ($ suffix).

Return None if empty.

aiosql.adapters.pg8000 module

class aiosql.adapters.pg8000.Pg8000Adapter(*args, **kwargs)

Bases: GenericAdapter

aiosql.adapters.pyformat module

class aiosql.adapters.pyformat.PyFormatAdapter(*args, **kwargs)

Bases: GenericAdapter

Convert from named to pyformat parameter style.

process_sql(query_name, op_type, sql)

From named to pyformat.

aiosql.adapters.sqlite3 module

class aiosql.adapters.sqlite3.SQLite3Adapter(*args, **kwargs)

Bases: GenericAdapter

SQLite3 Adapter for AioSQL.

Overwrites two methods using sqlite3-specific non-standard methods.

execute_script(conn, sql)

Handle an SQL script (# suffix).

insert_returning(conn, query_name, sql, parameters)

Special case for RETURNING (<! suffix) with SQLite.

Module contents