copyfix-dashboard / app /database.py
F1nnSBK's picture
feat: implement stateful instance segmentation drawing and local image streaming
766ef04
raw
history blame contribute delete
617 Bytes
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, declarative_base
from app.config import settings
# pool_pre_ping prevents stale connection errors common with remote clouds like Supabase
# pool_size and max_overflow keep us safely within Supabase free-tier connection limits
engine = create_engine(
settings.DATABASE_URL,
pool_pre_ping=True,
pool_size=5,
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()