s365b.db.session

Database engine and session factory.

Classes

Database

Holds the async engine and hands out sessions.

Module Contents

class s365b.db.session.Database(settings: s365b.core.config.Settings)[source]

Holds the async engine and hands out sessions.

Parameters:

settings – Settings providing database_url.

engine: sqlalchemy.ext.asyncio.AsyncEngine[source]
async session() → collections.abc.AsyncIterator[sqlalchemy.ext.asyncio.AsyncSession][source]

Open a session that commits on success and rolls back on error.

Yields:

The session.

async ping() → bool[source]

Check the database is reachable.

Returns:

True if a trivial query succeeds.

async dispose() → None[source]

Close all pooled connections.