boto python dynamodb扫描attribute_to_get [英] boto python dynamodb scan attributes_to_get
本文介绍了boto python dynamodb扫描attribute_to_get的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,
boto的文档充其量是模糊的,为什么这个操作不起作用?
Folks, The docs for boto are vague at best, why is this operation not working?
from boto.dynamodb2.table import Table
import time
print "Scanning Existing Database"
myTable = Table('myTable')
start = time.clock()
my_query = myTable.scan(scan_filter=None, attributes_to_get=['something'])
results = []
for x in my_query:
results.append(x['something'])
elapsed = (time.clock() - start)
print "Scan Operation took",elapsed
print len(results)
为什么这样做:
#!/bin/env python
import boto
db = boto.connect_dynamodb()
import time
print "Scanning Existing Database"
table = db.get_table('current_fhv_drivers')
start = time.clock()
all_query = table.scan(attributes_to_get=['something'])
results = []
for x in all_query:
results.append(x['something'])
elapsed = (time.clock() - start)
print "Scan Operation took",elapsed
print len(results)
推荐答案
如果正确设置配置,第一个代码示例必须可以工作在.boto文件中。
适用于我的任务。
First code example must work if you properly set configs in .boto file. It works for my tasks.
这篇关于boto python dynamodb扫描attribute_to_get的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文