harp_apps.storage.services.sql¶
- class SqlStorage[source]¶
Bases:
IStorage
Storage implementation using SQLAlchemy (async).
Currently supported/tested database drivers:
asyncpg (postgresql+asyncpg://…)
aiomysql (mysql+aiomysql://…)
asyncmy (mysql+asyncmy://…)
And also, for development/testing purposes:
aiosqlite (sqlite+aiosqlite://…)
Other async postgresql drivers may work, but as they’re not included in the test suite, you may have surprises. Contributions welcome.
- __init__(engine, blob_storage, settings)[source]¶
- Parameters:
engine (AsyncEngine)
blob_storage (IBlobStorage)
settings (StorageSettings)
- async create_users_once_ready(users)[source]¶
Sets the list of users to be created once the database is ready.
- async finalize()[source]¶
Coroutine function to finalize the instance. Should release resources, close files etc… The caller should make sure to call finalize on all cases where the instance is not needed anymore to get a clean shutdown.
- async get_transaction(id, /, *, username)[source]¶
Find a transaction, by id.
- Parameters:
- Return type:
Transaction | None
- async get_transaction_list(*, username, with_messages=False, filters=None, page=1, cursor='', text_search='')[source]¶
Implements
Storage.find_transactions
.
- async set_user_flag(*, transaction_id, username, flag, value=True)[source]¶
Sets or unsets a user flag on a transaction.
- async transactions_grouped_by_time_bucket(*, endpoint=None, time_bucket='day', start_datetime=None)[source]¶
- Parameters:
- Return type:
- engine: AsyncEngine¶
Reference to the sqlalchemy async engine, which is a gateway to the database connectivity, able to provide a connection used to execute queries.
- property worker¶