2

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.

1 Answer 1

1

You are looking for the batch_get_item method, check this question here for an example and the boto3 documentation here.

Sign up to request clarification or add additional context in comments.

1 Comment

That's exactly what I was looking for!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.