Rescue Paperjet v1 implementation
This commit is contained in:
parent
7ff5c8130d
commit
db9e2ca51b
83 changed files with 6186 additions and 3894 deletions
|
|
@ -4,11 +4,10 @@ Database engine, session management, and WAL mode setup.
|
|||
SQLite with WAL mode for single-user concurrent read/write safety.
|
||||
"""
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import event, create_engine, Engine
|
||||
from sqlalchemy import Engine, create_engine, event
|
||||
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker
|
||||
|
||||
from app.config import settings
|
||||
|
|
@ -16,6 +15,7 @@ from app.config import settings
|
|||
|
||||
class Base(DeclarativeBase):
|
||||
"""SQLAlchemy declarative base for all models."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -49,10 +49,10 @@ engine = create_db_engine()
|
|||
SessionLocal = sessionmaker(bind=engine, class_=Session, expire_on_commit=False)
|
||||
|
||||
|
||||
def get_db() -> Session:
|
||||
def get_db() -> Generator[Session, None, None]:
|
||||
"""FastAPI dependency that yields a database session."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db # type: ignore[misc]
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue