python - 在 boto3 中对 DynamoDB 查询进行分页

标签 python aws-lambda pagination amazon-dynamodb 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

最佳答案

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/

相关文章:

php - 开源投票系统

python - Flask - 在应用程序上下文之外工作

python - 尽管已安装,但我得到 'ImportError: No module named web'

aws-lambda - Serverless框架,API网关URL什么时候改变?

Django: "split"多个页面上的表单

java - Spring中List到Page的转换

python - 导入错误符号未找到 : __PySlice_AdjustIndices

node.js - 在 lambda 函数中获取 Aws iot thing 的 Thing Shadow

amazon-web-services - AWS Lambda CloudWatch 日志记录是否同步?

php - 如何使用原始查询在 laravel 5 中使用分页