2025-06-01 10:05:16 +00:00

16 lines
355 B
Python

from typing import Generator
from app.db.session import SessionLocal
# Dependency to get DB session
def get_db() -> Generator:
"""
Dependency for getting a database session.
This function yields a SQLAlchemy session and ensures it's closed after use.
"""
db = SessionLocal()
try:
yield db
finally:
db.close()