简体   繁体   中英

Querying dynamoDB with a list of elements

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.

EG

locations = ['Glasgow','London']

and the result of this to be elements with both locations.

您正在寻找batch_get_item方法,检查这里这个问题的一个例子,boto3文档这里

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM