server.web.db

Submodules

Attributes

DB

Functions

get_db(→ Generator[sqlalchemy.orm.Session, None, None])

Yield a SQLAlchemy Session managed inside a context-manager.

get_engine(→ sqlalchemy.engine.Engine)

Return the lazily-initialised SQLAlchemy engine.

get_dialect_name(→ str)

Lower-case dialect string, e.g. 'mysql', 'sqlite', 'postgresql'.

get_sessionmaker(→ sqlalchemy.orm.sessionmaker)

Get the SQLAlchemy sessionmaker singleton.

is_mysql(→ bool)

Check if the current database dialect is MySQL.

is_sqlite(→ bool)

Check if the current database dialect is SQLite.

apply_migrations(→ None)

Apply Alembic migrations to the database.

init_db(→ None)

Initialize the database: create if needed, apply migrations.

terminate_db(→ None)

Drop the database if it exists.

Package Contents

server.web.db.DB: Callable[[sqlalchemy.orm.Session], sqlalchemy.orm.Session][source]
server.web.db.get_db() Generator[sqlalchemy.orm.Session, None, None][source]

Yield a SQLAlchemy Session managed inside a context-manager.

server.web.db.get_engine() sqlalchemy.engine.Engine[source]

Return the lazily-initialised SQLAlchemy engine.

server.web.db.get_dialect_name() str[source]

Lower-case dialect string, e.g. ‘mysql’, ‘sqlite’, ‘postgresql’.

server.web.db.get_sessionmaker() sqlalchemy.orm.sessionmaker[source]

Get the SQLAlchemy sessionmaker singleton.

server.web.db.is_mysql() bool[source]

Check if the current database dialect is MySQL.

server.web.db.is_sqlite() bool[source]

Check if the current database dialect is SQLite.

server.web.db.apply_migrations(uri: str, revision: str = 'head') None[source]

Apply Alembic migrations to the database.

server.web.db.init_db(uri: str = '') None[source]

Initialize the database: create if needed, apply migrations.

server.web.db.terminate_db(uri: str) None[source]

Drop the database if it exists.