babylon.data.database

Database configuration and session management.

Provides SQLAlchemy engine and session configuration for the application. Uses SQLite for local persistence - simple, embedded, no server required.

Functions

get_db()

Get a database session.

Classes

Base(**kwargs)

Base class for all SQLAlchemy models.

class babylon.data.database.Base(**kwargs)[source]

Bases: DeclarativeBase

Base class for all SQLAlchemy models.

Parameters:

kwargs (Any)

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Parameters:
Return type:

None

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

See also

orm_declarative_metadata

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

babylon.data.database.get_db()[source]

Get a database session.

Yields:

Session – SQLAlchemy database session

Return type:

Iterator[Session]