Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
fastapi 'Depends' object has no attribute 'execute'

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

routers/company

@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.'
        )

controllers/company

async def getCompanySpecialization():
    return {
        "id": 1,
        "name": "ok"
    }
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!