reworded fastapi code

This commit is contained in:
Richie committed 2026-01-22 21:26:38 -05:00
1 parent cf4635922e
commit 258f918794
8 files changed
+339 -106

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
"""FastAPI dependencies."""
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)]