. KeyConditionExpression 仅支持 Key 类型的 Attribute 对象,amazon-dynamodb,python-3.6,boto3"/>

首页 > 解决方案 > 属性对象fundName的类型. KeyConditionExpression 仅支持 Key 类型的 Attribute 对象

问题描述

在 dynamoDB 表中进行查询时,我在 python 3, boto 3 中收到以下错误。

属性对象fundName 是类型。KeyConditionExpression 仅支持 Key 类型的 Attribute 对象

我在这行代码上遇到错误

response = table.query(KeyConditionExpression=Attr("fundName").eq(key))

fundName 是我的 dynamoDB 表的主键,我想获取确切的数据行。有人可以帮助指导我哪里错了。

标签: amazon-dynamodbpython-3.6boto3

解决方案


错误消息告诉我,如果有意义的话,您需要一个 Key 属性而不是 Attr one。

尝试:

response = table.query(KeyConditionExpression=Key("fundName").eq(key))

推荐阅读