async_db
- class mautrix.util.async_db.Database
Bases:
abc.ABC
- __init__(url, upgrade_table, db_args=None, log=None, owner_name=None, ignore_foreign_tables=True)
- Parameters
url (yarl.URL) –
upgrade_table (mautrix.util.async_db.UpgradeTable | None) –
log (Optional[mautrix.util.logging.TraceLogger]) –
owner_name (Optional[str]) –
ignore_foreign_tables (bool) –
- Return type
- abstract acquire()
- Return type
AsyncContextManager[mautrix.util.async_db.LoggingConnection]
- classmethod create(url, *, db_args=None, upgrade_table=None, log=None, owner_name=None, ignore_foreign_tables=True)
- Parameters
upgrade_table (Optional[Union[mautrix.util.async_db.UpgradeTable, str]]) –
log (Optional[Union[logging.Logger, mautrix.util.logging.TraceLogger]]) –
owner_name (Optional[str]) –
ignore_foreign_tables (bool) –
- Return type
- async execute(query, *args, timeout=None)
- async executemany(query, *args, timeout=None)
- async fetch(query, *args, timeout=None)
- async fetchrow(query, *args, timeout=None)
- async fetchval(query, *args, column=0, timeout=None)
- override_pool(db)
- Parameters
- Return type
- schemes: dict[str, Type[Database]] = {'cockroach': <class 'mautrix.util.async_db.PostgresDatabase'>, 'cockroachdb': <class 'mautrix.util.async_db.PostgresDatabase'>, 'postgres': <class 'mautrix.util.async_db.PostgresDatabase'>, 'postgresql': <class 'mautrix.util.async_db.PostgresDatabase'>, 'sqlite': <class 'mautrix.util.async_db.SQLiteDatabase'>, 'sqlite3': <class 'mautrix.util.async_db.SQLiteDatabase'>}
- log: TraceLogger
- url: URL
- upgrade_table: UpgradeTable | None
- class mautrix.util.async_db.UpgradeTable
Bases:
object
- __init__(allow_unsupported=False, version_table_name='version', database_name='database', log=None)
- Parameters
allow_unsupported (bool) –
version_table_name (str) –
database_name (str) –
log (Optional[Union[logging.Logger, mautrix.util.logging.TraceLogger]]) –
- Return type
- register(_outer_fn=None, *, index=- 1, description='', transaction=True, upgrades_to=None)
- Parameters
_outer_fn (Optional[Union[Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]], Callable[[mautrix.util.async_db.LoggingConnection], Awaitable[Optional[int]]]]]) –
index (int) –
description (str) –
transaction (bool) –
upgrades_to (Optional[Union[int, Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]]]]) –
- Return type
Union[Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]], Callable[[Union[Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]], Callable[[mautrix.util.async_db.LoggingConnection], Awaitable[Optional[int]]]]], Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]]]]
- async upgrade(db)
- Parameters
- Return type
- log: TraceLogger
- mautrix.util.async_db.register_upgrade(index=- 1, description='')
- Parameters
- Return type
Callable[[Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]]], Callable[[mautrix.util.async_db.LoggingConnection, mautrix.util.async_db.Scheme], Awaitable[Optional[int]]]]
- class mautrix.util.async_db.PostgresDatabase
Bases:
mautrix.util.async_db.Database
- __init__(url, upgrade_table, db_args=None, log=None, owner_name=None, ignore_foreign_tables=True)
- Parameters
url (yarl.URL) –
upgrade_table (mautrix.util.async_db.UpgradeTable) –
log (Optional[logging.Logger]) –
owner_name (Optional[str]) –
ignore_foreign_tables (bool) –
- Return type
- acquire()
- Return type
mautrix.util.async_db.LoggingConnection
- override_pool(db)
- Parameters
- Return type
- property pool: asyncpg.pool.Pool
- scheme = 'postgres'
- class mautrix.util.async_db.SQLiteDatabase
Bases:
mautrix.util.async_db.Database
- __init__(url, upgrade_table, db_args=None, log=None, owner_name=None, ignore_foreign_tables=True)
- Parameters
url (yarl.URL) –
upgrade_table (mautrix.util.async_db.UpgradeTable) –
log (Optional[logging.Logger]) –
owner_name (Optional[str]) –
ignore_foreign_tables (bool) –
- Return type
- acquire()
- Return type
AsyncContextManager[mautrix.util.async_db.LoggingConnection]
- override_pool(db)
- Parameters
- Return type
- scheme = 'sqlite'
- mautrix.util.async_db.SQLiteCursor
alias of
mautrix.util.async_db.Cursor
- mautrix.util.async_db.Connection
alias of
mautrix.util.async_db.LoggingConnection
- class mautrix.util.async_db.Scheme
Bases:
enum.Enum
An enumeration.
- POSTGRES = 'postgres'
- COCKROACH = 'cockroach'
- SQLITE = 'sqlite'
- exception mautrix.util.async_db.DatabaseException
Bases:
RuntimeError
- exception mautrix.util.async_db.DatabaseNotOwned
- exception mautrix.util.async_db.UnsupportedDatabaseVersion
Bases:
mautrix.util.async_db.DatabaseException
- __init__(name, version, latest)