adding website

This commit is contained in:
2026-04-28 22:50:53 -04:00
parent e75c077e16
commit 72eb2d8c3d
19 changed files with 3376 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
"""Database access for the FastAPI web app."""
from __future__ import annotations
from collections.abc import Iterator
from contextlib import contextmanager
from functools import lru_cache
from sqlalchemy.engine import Engine
from sqlalchemy.orm import Session
from pipelines.orm.common import get_postgres_engine
@lru_cache(maxsize=1)
def get_engine() -> Engine:
"""Return the lazily-created DATA_SCIENCE_DEV SQLAlchemy engine."""
return get_postgres_engine(name="DATA_SCIENCE_DEV")
def validate_database_connection() -> None:
"""Fail fast if the configured DATA_SCIENCE_DEV database is unavailable."""
with get_engine().connect():
pass
@contextmanager
def session_scope() -> Iterator[Session]:
"""Yield a SQLAlchemy session for a read-only request."""
with Session(get_engine()) as session:
yield session