Automated Action d60cfb5c4f Create Task Manager API with FastAPI and SQLite
- Set up FastAPI project structure
- Create Task model with SQLAlchemy
- Set up Alembic for migrations
- Create CRUD operations for tasks
- Implement API endpoints for tasks
- Add health check endpoint
- Update documentation

generated with BackendIM... (backend.im)
2025-05-13 23:23:43 +00:00

22 lines
520 B
Python

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