Automated Action d09d61a7c8 Implement Task Manager API with FastAPI and SQLite
- Created FastAPI application structure with main.py and requirements.txt
- Setup SQLite database with SQLAlchemy models for tasks
- Implemented Alembic migrations for database schema management
- Added CRUD endpoints for task management (GET, POST, PUT, DELETE)
- Configured CORS middleware to allow all origins
- Added health endpoint and base route with API information
- Updated README with comprehensive documentation
- Applied code formatting with Ruff linter
2025-06-24 14:17:11 +00:00

22 lines
512 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
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()