【发布时间】:2018-08-31 14:27:21
【问题描述】:
我正在尝试使用 boto3 使用 dynamodb 测试示例过滤器。我的简单示例 - 编写与documented 几乎相同 - 失败。我正在使用与.scan 正确配合使用的表“用户”:
In [24]: list(User.scan())
Out[24]: [users_info-dev<giovanni>, users_info-dev<nicola>, users_info-dev<ping>]
当试图过滤一个键时:
User.scan(FilterExpression=Attr('user_id').eq('giovanni'))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
...
ValueError: Attribute FilterExpression specified for filter does not exist.
from boto3.dynamodb.conditions import Key, Attr
什么是错误以及执行此扫描的正确方法是什么?
注意:我并没有真正了解扫描和查询之间的区别。似乎应该使用“查询”来过滤主键。对我来说听起来很奇怪的 SQL db 背景...
【问题讨论】:
标签: python amazon-dynamodb boto3