Automated Action d1c05cbd6e Implement Task Manager API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models for tasks and users with SQLAlchemy
- Configure Alembic for database migrations
- Implement authentication system with JWT tokens
- Create CRUD API endpoints for tasks and users
- Add health check endpoint
- Update README with documentation
2025-06-12 18:14:56 +00:00

26 lines
607 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
# Create storage directory if it doesn't exist
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = settings.SQLALCHEMY_DATABASE_URL
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()