
- Add SQLite database configuration - Create Todo model, schemas, and CRUD operations - Implement Todo API endpoints - Add Alembic migration for todo table - Set up database initialization in main.py - Update README with project details and instructions - Add pyproject.toml with Ruff configuration
17 lines
477 B
Python
17 lines
477 B
Python
from pathlib import Path
|
|
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
# Create a storage directory for the SQLite database
|
|
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) |