mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 04:58:19 -04:00
17 lines
413 B
Python
17 lines
413 B
Python
"""FastAPI dependencies for van inventory."""
|
|
|
|
from collections.abc import Iterator
|
|
from typing import Annotated
|
|
|
|
from fastapi import Depends, Request
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
def get_db(request: Request) -> Iterator[Session]:
|
|
"""Get database session from app state."""
|
|
with Session(request.app.state.engine) as session:
|
|
yield session
|
|
|
|
|
|
DbSession = Annotated[Session, Depends(get_db)]
|