Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda