mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-09-30 13:44:54 +02:00
25 lines
477 B
Python
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()
|