简体   繁体   中英

Query all rows from DynamoDB using python

As far as I went, there is very little information on how to retrieve all rows of a DynamoDB.

I used table.scan() But when using this method you have a limit, so you will not get all the items.

I tried table.query() But it says: Either the KeyConditions or KeyConditionExpression parameter must be specified in the request.

Thanks a lot

The only way is to use table.scan() but you will need to add consistent read.

Scan uses eventually consistent reads when accessing the data in a table; therefore, the result set might not include the changes to data in the table immediately before the operation began. If you need a consistent copy of the data, as of the time that the Scan begins, you can set the ConsistentRead parameter to true . Here is a link to the documentation. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.scan

If LastEvaluatedKey is empty, then the "last page" of results has been processed and there is no more data to be retrieved.

If LastEvaluatedKey is not empty, it does not necessarily mean that there is more data in the result set. The only way to know when you have reached the end of the result set is when LastEvaluatedKey is empty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM