AI_Virtual_Wardrobe / app /core /database.py
mata01's picture
Initialize production-grade FastAPI backend with models, routes, celery workers, and test suite
b18b789
Raw
History Blame Contribute Delete
454 Bytes
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, sessionmaker
from app.core.config import settings
engine = create_engine(
settings.sync_database_url,
pool_pre_ping=True,
pool_size=20,
max_overflow=10
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()