Scenario:
I want to retrieve items from DynamoDB table which has 200k records, I am trying to get them in multiple requests
- for first request I want 100 records only.
- for second request I want next 100 records, here I don't want the records which are already in first request.
My implementation:
scan_kwargs=None
if scan_kwargs is None:
scan_kwargs = {}
complete = False
while not complete:
try:
response = table.scan(Limit=10000, **scan_kwargs,
FilterExpression=Key('timestamp').between(dateFrom, dateTo)
)
except botocore.exceptions.ClientError as error:
raise Exception('Error')
next_key = response.get('LastEvaluatedKey')
scan_kwargs['ExclusiveStartKey'] = next_key
complete = True if next_key is None else False
if response['Items']:
for record in response['Items']:
print(record)
totalRecords = totalRecords + 1
if totalRecords > 100:
break
if totalRecords > 100:
break
From the above code I am only able to get first 100 records for multiple requests. But my requirement is to get from 101 to 200 records and ignore first 100 records
Can anyone help with working examples according to my requirement?