Automated Action ac56a7b6e5 Create comprehensive FastAPI REST API service
- Set up FastAPI application with SQLite database
- Implement User and Item models with relationships
- Add CRUD operations for users and items
- Configure Alembic for database migrations
- Include API documentation at /docs and /redoc
- Add health check endpoint at /health
- Enable CORS for all origins
- Structure code with proper separation of concerns
2025-06-25 11:20:01 +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()