1 Answer
- Newest
- Most votes
- Most comments
0
You can use the following code to achieve what you need:
import boto3
# get a list of items from dynamodb using pagination, default page size is 25 return all items
def get_items_from_dynamo_db(table_name, page_size=25, dynamodb=None):
if not dynamodb:
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(table_name)
response = table.scan(Limit=page_size)
items = response["Items"]
while "LastEvaluatedKey" in response:
response = table.scan(ExclusiveStartKey=response["LastEvaluatedKey"], Limit=page_size)
items.extend(response["Items"])
return items
For your reference, this code was generated by CodeWhisperer using the following 2 lines:
import boto3
# get a list of items from dynamodb using pagination, default page size is 25 return all items
Relevant content
- asked 2 years ago
- asked 4 years ago
- asked 8 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago