fitandsleek-vector / app /database.py
kalapak-team's picture
Improve Neon DATABASE_URL handling and clearer HF startup errors.
41ff887
Raw
History Blame Contribute Delete
489 Bytes
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, sessionmaker
from app.config import get_settings
settings = get_settings()
engine = create_engine(
settings.database_url,
pool_pre_ping=True,
pool_size=5,
max_overflow=10,
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
class Base(DeclarativeBase):
pass
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()