Automated Action 667ac548e1 Build complete FastAPI inventory management application
- Created FastAPI application structure with SQLAlchemy and Alembic
- Implemented full CRUD operations for inventory items
- Added search, filtering, and pagination capabilities
- Configured CORS, API documentation, and health endpoints
- Set up SQLite database with proper migrations
- Added comprehensive API documentation and README
2025-07-21 19:29:24 +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()