Skip to content

session

Database session and engine configuration.

Manages SQLAlchemy engine, session factory, and database settings.

SessionLocal module-attribute

SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)

Session factory for creating database sessions.

alembic_config module-attribute

alembic_config = AlembicConfig()

Global database configuration instance.

engine module-attribute

engine = create_engine(database_url, future=True)

SQLAlchemy engine connected to the configured database.

AlembicConfig

Pydantic settings for database connection configuration.

Manages database connection settings loaded from environment variables and .env files. Uses Pydantic's BaseSettings for validation and configuration management with support for nested environment variable names using double underscore delimiters.

ATTRIBUTE DESCRIPTION
database_url

SQL connection string in the format postgresql+psycopg2://user:password@host:port/database. Defaults to a local PostgreSQL instance at localhost:5432 with database name 'recipes'.

TYPE: str

Notes
  • Environment variable names can use __ (double underscore) as delimiters for nested configuration.
  • Configuration is loaded from .env file if present.
  • Extra environment variables are ignored.
  • Settings can be overridden via environment variables (e.g., DATABASE_URL overrides the default).