简体   繁体   English

使用元素列表查询 dynamoDB

[英]Querying dynamoDB with a list of elements

I need to design a script that queries dynamoDB with a list of elements.我需要设计一个脚本来查询带有元素列表的 dynamoDB。

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文档这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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