database

Standard SQLAlchemy models and different ways to open databases.

Package Contents

Classes

HasId

An SQLAlchemy mixin that provides an id column.

OpenMethod

Describes the way a database should be opened.

Functions

open_async_database_sqlite(...)

Open an SQLAlchemy SQLite async database.

open_database_sqlite(→ sqlalchemy.engine.Engine)

Open an SQLAlchemy SQLite database.

class HasId

Bases: sqlalchemy.orm.MappedAsDataclass

Inheritance diagram of experimentation.database.HasId

An SQLAlchemy mixin that provides an id column.

id: sqlalchemy.orm.Mapped[int]
class OpenMethod(*args, **kwds)

Bases: enum.Enum

Inheritance diagram of experimentation.database.OpenMethod

Describes the way a database should be opened.

OPEN_IF_EXISTS
OPEN_OR_CREATE
NOT_EXISTS_AND_CREATE
OVERWITE_IF_EXISTS
open_async_database_sqlite(db_file: str, open_method: experimentation.database._open_method.OpenMethod = OpenMethod.OPEN_IF_EXISTS) sqlalchemy.ext.asyncio.AsyncEngine

Open an SQLAlchemy SQLite async database.

Parameters:
  • db_file – File for the database.

  • open_method – The way the database should be opened.

Returns:

The opened database.

open_database_sqlite(db_file: str, open_method: experimentation.database._open_method.OpenMethod = OpenMethod.OPEN_IF_EXISTS) sqlalchemy.engine.Engine

Open an SQLAlchemy SQLite database.

Parameters:
  • db_file – File for the database.

  • open_method – The way the database should be opened.

Returns:

The opened database.