Files
rengine/worker/app/database.py
T

25 lines
477 B
Python

"""Sync database session for Celery workers."""
from sqlalchemy import create_engine
from sqlalchemy.orm import Session, sessionmaker
from app.config import settings
engine = create_engine(
settings.database_url,
echo=settings.DEBUG,
pool_pre_ping=True,
pool_size=5,
max_overflow=10,
)
SyncSessionLocal = sessionmaker(
bind=engine,
class_=Session,
expire_on_commit=False,
)
def get_sync_session() -> Session:
return SyncSessionLocal()