SIEPEX - Python e FastAPI

Pasted Oct 29, 2026, 9:50 AM4 files1,129 linesexpires in 12 h

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/siepex-python-fastapi
database.py
from collections.abc import Generator
from pathlib import Path

from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker

DATABASE_URL = (
    f"sqlite:///{Path(__file__).parent / 'todo.db'}"
)

engine = create_engine(
    DATABASE_URL,
    connect_args={"check_same_thread": False},
)

SessionLocal = sessionmaker(
    bind=engine,
    autoflush=False,
    expire_on_commit=False,
)

def db_session() -> Generator[Session, None, None]:
    with SessionLocal() as session:
        yield session

class Base(DeclarativeBase):
    pass

27,388 chars · codepastes.com