fastapi-boilerplate/app/api/deps.py

12 lines
182 B
Python
Raw Normal View History

from typing import Generator
from db.database import SessionLocal
def get_db() -> Generator:
try:
db = SessionLocal()
yield db
finally:
db.close()