Automated Action 9d9801c0d0 Create FastAPI REST API service
- Add FastAPI application with CORS support
- Implement SQLite database with SQLAlchemy
- Create Item model with CRUD operations
- Setup Alembic for database migrations
- Add comprehensive API endpoints for Items
- Include health check endpoint
- Update README with documentation
2025-06-19 20:27:19 +00:00

22 lines
512 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()