【问题标题】:How do I loop over all items in a DynamoDB table using boto?如何使用 boto 遍历 DynamoDB 表中的所有项目?
【发布时间】:2012-01-23 00:35:08
【问题描述】:

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

【问题讨论】:

  • 看起来从 v2.1.1 boto 开始不支持表扫描。现在,将我的哈希键更改为使用公共值并使用查询来查询该值

标签: python boto amazon-dynamodb


【解决方案1】:

Chris Moyer 在commit 522e0548 中将Scan API 的初步支持添加到 boto 的用于 DynamoDB 的 layer2(添加了对 layer2 和表的扫描),同时由 Mitch Garnaat 在@ 987654323@(清理了 Layer2 和 Table 上的扫描方法。)隐藏 layer1 详细信息并启用直观查询 - 各自的 issue #574 目前计划与 boto 2.3 一起发布。

通过tests/dynamodb/test_layer2.py 隐式包含使用示例:

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多