
- Create FastAPI application with CORS support - Add SQLAlchemy models for Todo with timestamps - Set up SQLite database with proper configuration - Create CRUD operations for todo management - Add REST API endpoints for all todo operations - Configure Alembic for database migrations - Add Pydantic schemas for request/response validation - Include health check and root info endpoints - Set up proper project structure following best practices - Add comprehensive README with usage instructions
19 lines
523 B
Python
19 lines
523 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() |