made fastapi tools

This commit is contained in:
Richie committed 2026-06-14 15:41:09 -04:00
1 parent 8301db39e5
commit c53afb3c70
6 files changed
+10 -4

No files matched your search

+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)]