made fastapi tools

This commit is contained in:
2026-06-12 14:45:10 -04:00
parent 8301db39e5
commit c53afb3c70
6 changed files with 10 additions and 4 deletions
+20
View File
@@ -0,0 +1,20 @@
"""FastAPI dependencies."""
from __future__ import annotations
from typing import TYPE_CHECKING, Annotated
from fastapi import Depends, Request
from sqlalchemy.orm import Session
if TYPE_CHECKING:
from collections.abc import Iterator
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)]