Automated Action f63bd5104b Add Task Manager API with FastAPI and SQLite
- Created FastAPI application structure with main.py
- Implemented SQLAlchemy models for tasks with priority and completion status
- Set up database connection with SQLite using absolute paths
- Created Alembic migrations for database schema
- Added CRUD operations for task management
- Implemented health check and root endpoints
- Added CORS configuration for cross-origin requests
- Created comprehensive API documentation
- Added Ruff configuration for code linting
- Updated README with installation and usage instructions
2025-06-24 07:52:20 +00:00

27 lines
614 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pathlib import Path
from app.db.base import Base
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)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
def create_tables():
Base.metadata.create_all(bind=engine)