0

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---------")
  • Does this answer your question? [Complete scan of dynamoDb with boto3](https://stackoverflow.com/questions/36780856/complete-scan-of-dynamodb-with-boto3) – lvthillo Sep 17 '21 at 22:12
  • @lvthillo, unfortunately its not working. I am able to display 1MB size of data, however not the further data. What i observed that my response does not contain LastEvaluatedKey at all, hence " while 'LastEvaluatedKey' in response:" loop is not getting executed. Any suggestion? – AWS_explorer Sep 20 '21 at 21:19
  • What is being returned? – Coin Graham Sep 21 '21 at 21:17
  • i am simply getting response with all details however LastEvaluatedKey is missing. – AWS_explorer Sep 22 '21 at 18:46
  • You're certain that you have more data to scan because your tooling tells you otherwise? – Atmas Sep 26 '21 at 03:15
  • I guess, i did not have enough data so LastEvaluatedKey was not present in Response. When i ran against large volume of data, i could found LastEvaluatedKey . – AWS_explorer Sep 27 '21 at 14:25

0 Answers0