Automated Action 5dca451d03 Add SQLAlchemy database setup with Todo model
- Add app/db/base.py with SQLAlchemy Base class
- Add app/db/session.py with SQLite database connection using absolute path
- Add app/models/todo.py with Todo model including all required fields
- Add empty __init__.py files for proper package structure
2025-06-19 17:46:14 +00:00

19 lines
515 B
Python

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from pathlib import Path
# Database setup
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()