I was trying to call an asynchronous function inside my async route function, I got this error the exception is 'Depends' object has no attribute 'execute', the line that causes the error was company_specialization = await getCompanySpecialization() I wonder why I can not do this?!!
This is a part of the code
@router.get('/Company/{id}')
async def getCompanyItem(id: int, db: Session = Depends(get_async_session)):
try:
query = select(Company).where(Company.id == id)
results = await db.execute(query)
data = results.scalars().first()
if not data:
raise HTTPException(
status_code=404,
detail="Utilisateur non trouvé"
)
else:
company_specialization = await getCompanySpecialization()
return {
"success": "True",
'data': data
}
except Exception as e:
print("the exception is ", e)
raise HTTPException(
status_code=500,
detail=f'Une erreur est survenue, veuillez réessayer ultérieurement.'
)
async def getCompanySpecialization():
return {
"id": 1,
"name": "ok"
}