Reputation: 441
Please I need help writing filter expressions for scanning data in dynamo db tables using python and boto3.
See my code below.
For some reason unknown to me, this search filter below which I am using is not giving me the right results
Please advice
dynamo_db = boto3.resource('dynamodb')
table = dynamo_db.Table(TABLE_NAME)
my_kwargs = {
'FilterExpression': Key('column_1').eq(val_type_1) and Key("column_2").eq("val_type_string")
}
response = table.scan(**my_kwargs)
items = response['Items']
table_item = items[0]
Upvotes: 0
Views: 1777
Reputation: 19893
When you use Scan you do not filter on Key
. You filter here is in an attribute so you will need to change Key
to Attr
.
Furthermore you will need to implement pagination if you are scanning more than 1Mb of data:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html
Upvotes: 1