app.init_db module#

Initialize the database schema by creating all ORM tables.

This module provides a thin, dependency-free CLI wrapper around app.database.ensure_database_schema so that schema creation can be invoked from containers, CI jobs, or local development shells. It does not perform any application bootstrapping beyond configuring logging and calling the database utility.

See Also#

app.database.ensure_database_schema

Create DB tables via the shared helper.

app.config.settings

Runtime configuration values.

Notes#

  • Primary role: minimal CLI to delegate schema creation to app.database.ensure_database_schema.

  • Key dependencies: a valid app.config.settings.DATABASE_URL and a reachable database service.

  • Invariants: the operation is idempotent and safe to re-run; if all tables already exist, no changes are made.

Examples#

>>> # Programmatic usage
>>> from app.init_db import initialize_database_schema
>>> initialize_database_schema()
app.init_db.initialize_database_schema() None[source]#

Create all ORM tables in the configured database.

Delegates to app.database.ensure_database_schema() and logs the outcome. This function is idempotent and may be called multiple times without side effects if the schema already exists.

Raises:
SQLAlchemyError

If schema initialization fails (e.g., connectivity or permissions).

See also

app.database.ensure_database_schema

Create DB tables via the shared helper.

app.init_db.main() None[source]#

CLI entry point to initialize the database schema.

Parses arguments, configures logging, and calls initialize_database_schema().

Raises:
SQLAlchemyError

Propagated from initialize_database_schema() when schema initialization fails.

Examples

>>> # From a shell (inside the environment)
>>> python -m app.init_db --log-level DEBUG
app.init_db.parse_args() Namespace[source]#

Parse command-line arguments.

Returns:
argparse.Namespace

Parsed arguments, including log-level.

Notes

The --log-level argument is constrained to LOG_LEVEL_CHOICES to prevent invalid values.