Async and sync SQLAlchemy session factories.
Source: web/backend/database.py
Provides both async (for FastAPI request handlers) and sync (for Celery workers) SQLAlchemy session factories. Uses PostgreSQL via asyncpg.
| Export | Type | Used By |
|---|---|---|
async_session_factory |
async_sessionmaker |
FastAPI routers |
sync_session_factory |
sessionmaker |
Celery tasks |
get_async_session() |
FastAPI Dependency | Router dependency injection |
get_sync_session() |
context manager | Celery task code |
asyncpg for non-blocking DB callsBoth connect to the same PostgreSQL database via different connection strings from Web Config.
Web Database
├── SQLAlchemy (async + sync)
├── asyncpg
├── Web Config (DATABASE_URL, SYNC_DATABASE_URL)
├── DB Models (table definitions)
└──▶ consumed by FastAPI App (lifecycle)
├──▶ Uploads Router
├──▶ Jobs Router
├──▶ Events Router
└──▶ Pipeline Tasks