gpt4 book ai didi

amazon-web-services - 使用Boto3的DynamoDB分页

转载 作者:行者123 更新时间:2023-12-03 13:45:16 28 4
gpt4 key购买 nike

我们在我们的DynamoDB中使用了boto3,我们需要对表进行全面扫描,以根据需要进行分页的其他帖子来做到这一点。但是,我们找不到分页的有效示例。这就是我们所做的。

import boto3
client_setting = boto3.client('dynamodb', region_name='ap-southeast-2')
paginator = client_setting.get_paginator('scan')
esk = {}
data = []
unconverted_ga = ourQuery(params1, params2)
for page in unconverted_ga:
data.append(page)
esk = page['LastEvaluatedKey']

我们不知道如何使esk成为我们下一个查询的ExclusiveStartKey。 ExclusiveStartkey参数的期望值应该是多少? DynamoDB仍然是我们的新手,包括这在内,我们需要学习很多东西。谢谢!

最佳答案

来自Tay B在https://stackoverflow.com/a/38619425/3176550的回答

import boto3
dynamodb = boto3.resource('dynamodb',
aws_session_token=aws_session_token,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
region_name=region
)

table = dynamodb.Table('widgetsTableName')

response = table.scan()
data = response['Items']

while 'LastEvaluatedKey' in response:
response = table.scan(ExclusiveStartKey=response['LastEvaluatedKey'])
data.update(response['Items'])

关于amazon-web-services - 使用Boto3的DynamoDB分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38386519/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com