Reputation: 73
I need to design a script that queries dynamoDB with a list of elements.
I've already tried looping over every element of the list, and querying that element and appending the result, but I was wondering if there is a more efficient way of performing that operation.
KeyConditionExpression=Key('id').eq('occupation') & Key('sort').begins_with(locations + '#' + occup + '#' + contract)
The code I've shown above performs a query for a single location, but instead of just one I wonder if I use the list and sort of lower the number of queries.
E.G.
locations = ['Glasgow','London']
and the result of this to be elements with both locations.
Upvotes: 2
Views: 861
Reputation: 7119
You are looking for the batch_get_item
method, check this question here for an example and the boto3 documentation here.
Upvotes: 1