моя конечная точка выглядит примерно так:
Код: Выделить всё
@router.get('/{activity_id}')
async def get_activity_detail(param_1: int,
response: Response,
creds: Creds = Depends(),
db:SQLServer = Depends(get_db):
# Does something
Код: Выделить всё
def get_db() -> Generator: # coverage: omit
try:
db = SessionLocal()
yield db
except Exception as e:
print(f'Error : raised from {inspect.stack()[0][3]} - {str(e)}')
raise
finally:
db.close()
print(f'Closing the database connection')

Я не ожидал ошибок. Я пытался следовать официальной документации: https://fastapi.tiangolo.com/tutorial/d ... ith-yield/. Но поскольку я новичок в FastAPI, мне сложно найти решение.
Подробнее здесь: https://stackoverflow.com/questions/791 ... didnt-stop