mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
format and lint
This commit is contained in:
parent
e2f01f89c5
commit
700a2d49a6
@ -1,9 +1,9 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
from rotoger import AppStructLogger
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
|
||||
from app.config import settings as global_settings
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import orjson
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
from fastapi.responses import JSONResponse
|
||||
from rotoger import AppStructLogger
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
|
||||
logger = AppStructLogger().get_logger()
|
||||
|
||||
|
||||
# TODO: add reasoning for this in readme plus higligh using re-raise in db session
|
||||
async def sqlalchemy_exception_handler(
|
||||
request: Request, exc: SQLAlchemyError
|
||||
@ -76,4 +77,6 @@ async def response_validation_exception_handler(
|
||||
def register_exception_handlers(app: FastAPI) -> None:
|
||||
"""Register all exception handlers with the FastAPI app."""
|
||||
app.add_exception_handler(SQLAlchemyError, sqlalchemy_exception_handler)
|
||||
app.add_exception_handler(ResponseValidationError, response_validation_exception_handler)
|
||||
app.add_exception_handler(
|
||||
ResponseValidationError, response_validation_exception_handler
|
||||
)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import uuid
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
from sqlalchemy import String, select
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
@ -25,5 +24,3 @@ class Nonsense(Base):
|
||||
result = await db_session.execute(stmt)
|
||||
instance = result.scalars().first()
|
||||
return instance
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user