Skip to content

calista.config

calista.config

Configuration utilities for CALISTA.

This module centralizes small helpers and constants related to application configuration.

DatabaseUrlNotSetError

Bases: Exception

Raised when the CALISTA_DB_URL environment variable is not set.

get_db_url()

Get the database URL from the environment.

Returns:

Type Description
str

The value of the CALISTA_DB_URL environment variable.

Raises:

Type Description
DatabaseUrlNotSetError

If CALISTA_DB_URL is not set.

build_alembic_config(db_url=None, stdout=sys.stdout)

Build an Alembic Config object for CALISTA's migrations.

Sets only Alembic "main" options: - sqlalchemy.url → the database URL you pass - script_location → CALISTA's packaged Alembic scripts

Parameters:

Name Type Description Default
db_url str | None

SQLAlchemy database URL (e.g., sqlite:///:memory: or postgresql+psycopg://user:pass@host/dbname). Can be None (default) only in contexts where Alembic won't need to connect to the DB.

None
stdout TextIO

Text stream Alembic will write status lines to. Defaults to sys.stdout; override in tests to capture output.

stdout

Returns:

Type Description
Config

An alembic.config.Config pointing to CALISTA's migration scripts.