在boto3中分页DynamoDB查询

时间:2016-09-06 18:14:34

标签: python pagination aws-lambda boto3

如果它们跨越多个页面,我如何遍历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

1 个答案:

答案 0 :(得分:1)

ExclusiveStartKey是您要查找的属性的名称。 使用上一操作中为LastEvaluatedKey返回的值。

ExclusiveStartKey的数据类型必须是String,Number或Binary。不允许设置任何数据类型。

http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.query