如果 DynamoDB 查询中的所有结果跨越一页以上,我如何循环遍历这些结果? This answer暗示分页内置于查询函数中(至少在 v2 中),但是当我在 v3 中尝试此操作时,我的项目似乎有限:
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb')
fooTable = dynamodb.Table('Foo')
response = fooTable.query(
KeyConditionExpression=Key('list_id').eq('123')
)
count = 0
for i in response['Items']:
count += 1
print count # Prints a subset of my total items
最佳答案
ExclusiveStartKey 是您要查找的属性的名称。 使用在上一个操作中为 LastEvaluatedKey 返回的值。
ExclusiveStartKey 的数据类型必须是字符串、数字或二进制。不允许设置数据类型。
http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.query
关于python - 在 boto3 中对 DynamoDB 查询进行分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39355377/