I'm trying to test sample filters with dynamodb using boto3. My simple example -written almost identical to the documented one- fails. I'm using a Table 'User' that correctly works with .scan
:
In [24]: list(User.scan())
Out[24]: [users_info-dev<giovanni>, users_info-dev<nicola>, users_info-dev<ping>]
When trying to filter on a key:
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
What's the error and which is the correct way to execute this scan?
Note: I have not really got the difference between scan and query. It seems 'query' should be used for filtering on primary key. Having a background on SQL db that sounds wierd to me...
I didn't realize that I was using a wrappwer around the table provided by pynamodb. The table was not a table provided by boto3 but by pynamodb, so that the syntax for the query/scan are different (and simpler):
User.scan(User.user_id == 'giovanni')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.