FastAPI - Database Integration
What is wrong with this SQLAlchemy session management in FastAPI?
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
@app.get('/items')
def read_items(db: Session = Depends(get_db)):
return db.query(Item).all()