Paginating a DynamoDB query in boto3
<p>How can I loop through all results in a DynamoDB query, if they span more than one page? <a href="http://stackoverflow.com/a/13178258/526495">This answer</a> implies that pagination is built into the query function (at least in v2), but when I try this in v3, my items seem limited:</p>

<pre><code>import boto3
from boto3.dynamodb.conditions import Key, Attr

dynamodb = boto3.resource('dynamodb')
fooTable = dynamodb.Table('Foo')
response = fooTable.query(
    KeyConditionExpression=Key('list_id').eq('123')
)

count = 0

for i in response['Items']:
    count += 1

print count # Prints a subset of my total items
</code></pre>

<p>ExclusiveStartKey is the name of the attribute which you are looking for.
Use the value that was returned for LastEvaluatedKey in the previous operation.</p>

<p>The data type for ExclusiveStartKey must be String, Number or Binary. No set data types are allowed.</p>

<p><a href="http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.query" rel="nofollow">http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.query</a></p>

python pagination aws-lambda boto3