I have a Python program to scan all the records from DynamoDB table, however its not retrieving all the records. I am using LastEvaluatedKey to scan all the records due to 1mb record retrieval limitation. it looks like LastEvaluatedKey is not present in my response. Can someone please help?
import json
import sys
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb')
def lambda_handler(event, context):
table = dynamodb.Table('Your_Table_Name')
queryCount = 1
response = table.scan()
print("Total Records:-", response['ScannedCount'])
#Extract the Results
items = response['Items']
for item in items:
print(item)
queryCount = queryCount + 1
while 'LastEvaluatedKey' in response:
print('1---------')
key = response['LastEvaluatedKey']
response = table.scan(ExclusiveStartKey=key)
items = response['Items']
for item in items:
queryCount = queryCount + 1
print("2---------")