amazon-dynamodb - 属性对象fundName的类型. KeyConditionExpression 仅支持 Key 类型的 Attribute 对象
问题描述
在 dynamoDB 表中进行查询时,我在 python 3, boto 3 中收到以下错误。
属性对象fundName 是类型。KeyConditionExpression 仅支持 Key 类型的 Attribute 对象
我在这行代码上遇到错误
response = table.query(KeyConditionExpression=Attr("fundName").eq(key))
fundName 是我的 dynamoDB 表的主键,我想获取确切的数据行。有人可以帮助指导我哪里错了。
解决方案
错误消息告诉我,如果有意义的话,您需要一个 Key 属性而不是 Attr one。
尝试:
response = table.query(KeyConditionExpression=Key("fundName").eq(key))
推荐阅读
- python - Pandas Ordered Categorical 未按预期工作
- mysql - 如何在mysql中获取表的转置
- r - 在 R 中,在字符串中,有没有办法为正则表达式中被视为特殊的字符添加双反斜杠
- python - Python - 保存到 PDF 屏幕未在 chrome 85.0.4183.102 中显示
- c++ - 无论如何,如果条件与 C++ 模板一起链接多个?
- python - 类型错误:__init__() 缺少 1 个必需的位置参数:“单位”'
- python - 以下用于求幂的分治递归算法是否比用于大数的迭代算法更有效?
- php - 在 Laravel 集合上混合数组
- wordpress - 如何防止短代码被多次执行
- python - Matplotlib fill_between 从零归档时显示一条白色