code format

This commit is contained in:
Jakub Miazek
2024-04-24 10:37:08 +02:00
parent 43fe665608
commit c2975fd260
19 changed files with 358 additions and 173 deletions

View File

@@ -26,7 +26,9 @@ class Base(DeclarativeBase):
db_session.add(self)
return await db_session.commit()
except SQLAlchemyError as ex:
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)) from ex
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)
) from ex
async def delete(self, db_session: AsyncSession):
"""
@@ -39,7 +41,9 @@ class Base(DeclarativeBase):
await db_session.commit()
return True
except SQLAlchemyError as ex:
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)) from ex
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)
) from ex
async def update(self, db: AsyncSession, **kwargs):
"""
@@ -53,7 +57,9 @@ class Base(DeclarativeBase):
setattr(self, k, v)
return await db.commit()
except SQLAlchemyError as ex:
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)) from ex
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=repr(ex)
) from ex
async def save_or_update(self, db: AsyncSession):
try: