initial skeleton: FastAPI + SQLAlchemy + schema rendicontazione + template RE-START

This commit is contained in:
BFLOWS
2026-04-18 07:50:06 +02:00
commit 63fd2f66e6
14 changed files with 602 additions and 0 deletions

24
app/db.py Normal file
View File

@@ -0,0 +1,24 @@
from sqlalchemy import create_engine, event
from sqlalchemy.orm import sessionmaker, declarative_base
from .config import get_settings
settings = get_settings()
engine = create_engine(
settings.db_url,
pool_pre_ping=True,
pool_size=5,
max_overflow=10,
connect_args={"options": f"-csearch_path={settings.db_schema},public"}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()