我正在尝试返回操作列表并收到错误
@router.get("/")
async def get_specific_operations(operation_type: str, session: AsyncSession = Depends(get_async_session)):
query = select(operation).where(operation.c.type == operation_type)
result = await session.execute(query)
return result.all()
错误:
ValueError: [TypeError('cannot convert dictionary update sequence element #0 to a sequence'), TypeError('vars() argument must have __dict__ attribute')]
最佳答案
尝试代替 result.all()
来执行此操作 result.scalars().all()
关于python - FastAPI SQLAlchemy 无法将字典更新序列元素 #0 转换为序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76322342/