git-subtree-dir: fiscal git-subtree-mainline:d95165fc8fgit-subtree-split:102ba84500
16 lines
508 B
Python
16 lines
508 B
Python
"""SQLAlchemy session setup for central PostgreSQL only."""
|
|
from sqlalchemy import create_engine, text
|
|
from sqlalchemy.orm import sessionmaker
|
|
from .config import settings
|
|
|
|
engine = create_engine(settings.database_url, pool_pre_ping=True)
|
|
SessionLocal = sessionmaker(bind=engine, expire_on_commit=False)
|
|
|
|
def database_is_available() -> bool:
|
|
try:
|
|
with engine.connect() as connection:
|
|
connection.execute(text("SELECT 1"))
|
|
return True
|
|
except Exception:
|
|
return False
|