mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
- add decorator to compile sql for pool or return scalar from statement
This commit is contained in:
@@ -45,7 +45,10 @@ async def create_stuff(
|
||||
async def find_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
|
||||
result = await Stuff.find(db_session, name)
|
||||
if not result:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Stuff with name {name} not found.")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Stuff with name {name} not found.",
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
@@ -91,7 +94,6 @@ async def find_stuff_pool(
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@router.delete("/{name}")
|
||||
async def delete_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
|
||||
stuff = await Stuff.find(db_session, name)
|
||||
|
||||
Reference in New Issue
Block a user