Automated Action 980c575291 Finish up the Todo application
- Fixed database connection path to match BackendIM requirements
- Implemented filter by completion status in the todos endpoint
- Fixed updated_at timestamp to automatically update
- Updated alembic.ini with the correct database URL

generated with BackendIM... (backend.im)
2025-05-13 06:05:28 +00:00

28 lines
674 B
Python

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from pathlib import Path
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
def create_db_and_tables():
Base.metadata.create_all(bind=engine)