Utility for paginating through a BOTO3 dynamodb result for resource/tables
See original GitHub issueIs your feature request related to a problem? Please describe.
When fetching a record set that requires pagination you have to implement something quite awkward. And if don’t naively, you could run into memory issues.
dynamodb.Table = boto3.resource("dynamodb")
large_table = dynamodb.Table("TableWithLotsOfData")
# Scan or Query with lots of data
response = large_table.scan()
items = response["Items"]
while "LastEvaluatedKey" in response:
# Add ExclusiveStartKey to the original operation
response = table.scan(ExclusiveStartKey=response["LastEvaluatedKey"])
items.update(response["Items"])
or use DynamoDB.Paginator.Query.paginate
client = boto3.client("dynamodb")
paginator = client.get_paginator("scan")
params = {}
for page in paginator.paginate(params):
# do something
Describe the solution you’d like
Build a custom iterator (much like how the Java AWS SDK has), which can automatically fetch more data as needed.
Describe alternatives you’ve considered
- Building a small local library for this
- doing the naive example.
- Log an issue with boto3 library
Additional context
- Java AWS SDK V1 PaginatedQueryList
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
DynamoDB Table Resource should support Pagination for ...
Utility for paginating through a BOTO3 dynamodb result for resource/tables awslabs/aws-lambda-powertools-python#593.
Read more >DynamoDB — Boto3 Docs 1.26.34 documentation - AWS
With DynamoDB, you can create database tables that can store and retrieve any amount of data, and serve any level of request traffic....
Read more >DynamoDB pagination using Boto3 - Stack Overflow
However, we are unable to find a working sample of pagination. Here is what we did. import boto3 client_setting = boto3.client('dynamodb', ...
Read more >Paginating table query results - Amazon DynamoDB
DynamoDB paginates the results from Query operations. With pagination, the Query results are divided into "pages" of data that are 1 MB in...
Read more >DynamoDB Python Boto3 Query Cheat Sheet [14 Examples]
This cheat sheet covers the most important DynamoDB Boto3 query examples that you can use for your next DynamoDB Python project.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@michaelbrewer I’ve been using PynamoDB for the past year and can confirm it’s awesome and makes life much easier with DynamdoDB.
Thanks for opening that.
That’s been an old request asking boto to port the pagination that boto3 DynamoDB client has onto the resource
https://github.com/boto/boto3/issues/2039
This is one among other suboptimal UX issues that makes Pynamodb be a better solution
https://pynamodb.readthedocs.io/en/latest/