如何使用Boto遍历DynamoDB表中的所有项目? [英] How do I loop over all items in a DynamoDB table using boto?

查看:234
本文介绍了如何使用Boto遍历DynamoDB表中的所有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查询DynamoDB表并检索所有项目,然后使用boto遍历它们。如何构造查询或扫描以返回表中的所有内容?

I'd like to query a DynamoDB table and retrieve all the items and loop over them using boto. How do I structure a query or scan that returns everything in the table?

推荐答案

扫描API 添加到boto的DynamoDB的layer2中。 //github.com/boto/boto/commit/522e054866899d6acf8b08d5ae8ff3e447e81c6e rel = nofollow>提交522e0548 (已将扫描添加到layer2和Table ),并已由Mitch Garnaat在提交adeb7151 清除了Layer2和Table上的扫描方法。)隐藏第1层详细信息并启用直观查询-当前相应的问题#574 计划与 boto 2.3

Preliminary support for the Scan API had been added to boto's layer2 for DynamoDB by Chris Moyer in commit 522e0548 (Added scan to layer2 and Table) and has meanwhile been updated by Mitch Garnaat in commit adeb7151 (Cleaned up the scan method on Layer2 and Table.) to hide the layer1 details and enable intuitive querying - the respective issue #574 is currently scheduled to be released with boto 2.3.

用法示例通过< a href = https://github.com/boto/boto/commit/adeb715194a9d0e78d0e5f41638782c68c0071f8#diff-2 rel = nofollow> tests / dynamodb / test_layer2.py :

# Try scans
results = table.scan([('Tags', 'CONTAINS', 'table')])
n = 0
for item in results:
    n += 1
assert n == 2

这篇关于如何使用Boto遍历DynamoDB表中的所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆