server.web.db ============= .. py:module:: server.web.db Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/server/web/db/deps/index /autoapi/server/web/db/dns/index /autoapi/server/web/db/engine/index /autoapi/server/web/db/migrate/index Attributes ---------- .. autoapisummary:: server.web.db.DB Functions --------- .. autoapisummary:: server.web.db.get_db server.web.db.get_engine server.web.db.get_dialect_name server.web.db.get_sessionmaker server.web.db.is_mysql server.web.db.is_sqlite server.web.db.apply_migrations server.web.db.init_db server.web.db.terminate_db Package Contents ---------------- .. py:data:: DB :type: Callable[[sqlalchemy.orm.Session], sqlalchemy.orm.Session] .. py:function:: get_db() -> Generator[sqlalchemy.orm.Session, None, None] Yield a SQLAlchemy Session managed inside a context-manager. .. py:function:: get_engine() -> sqlalchemy.engine.Engine Return the lazily-initialised SQLAlchemy engine. .. py:function:: get_dialect_name() -> str Lower-case dialect string, e.g. 'mysql', 'sqlite', 'postgresql'. .. py:function:: get_sessionmaker() -> sqlalchemy.orm.sessionmaker Get the SQLAlchemy sessionmaker singleton. .. py:function:: is_mysql() -> bool Check if the current database dialect is MySQL. .. py:function:: is_sqlite() -> bool Check if the current database dialect is SQLite. .. py:function:: apply_migrations(uri: str, revision: str = 'head') -> None Apply Alembic migrations to the database. .. py:function:: init_db(uri: str = '') -> None Initialize the database: create if needed, apply migrations. .. py:function:: terminate_db(uri: str) -> None Drop the database if it exists.