report_generation/database/dependencies.py
xxy 43f3e0b746 Initial commit
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 18:41:06 +08:00

21 lines
357 B
Python

"""
database/dependencies.py
FastAPI 依赖注入:获取数据库 Session。
"""
from __future__ import annotations
from typing import Generator
from sqlalchemy.orm import Session
from database.core import SessionLocal
def get_db() -> Generator[Session, None, None]:
db = SessionLocal()
try:
yield db
finally:
db.close()