Automated Action ecb15eb903 Build complete task management tool with FastAPI
- Implemented full CRUD operations for tasks
- Added SQLite database with SQLAlchemy ORM
- Set up Alembic migrations for database schema
- Created health check and base URL endpoints
- Added CORS middleware for cross-origin requests
- Included comprehensive API documentation
- Updated README with complete project information
2025-06-20 03:21:46 +00:00

23 lines
521 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()