
- 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
26 lines
607 B
Python
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() |