之前有人遇到过这个问题吗?
import boto
conn = boto.dynamodb.connect_to_region('eu-west-1', aws_access_key_id=aws_key, aws_secret_access_key=aws_secret)
table = conn.get_table('TweetSample')
print table.scan(limit=1)
错误:
Traceback (most recent call last):
File "test.py", line 9, in <module>
print table.scan(limit=1)
File "table.py", line 518, in scan
return self.layer2.scan(self, *args, **kw)
TypeError: scan() got an unexpected keyword argument 'limit'
[Finished in 0.4s with exit code 1]
我甚至都不知道......
答案 0 :(得分:0)
根据文档,scan
method的boto.dynamodb.table.Table
(由boto.dynamodb.layer2.Layer2.get_table
返回)不接受limit
,但max_results
。
结果是一台发电机。所以,如果你想打印它,你应该迭代它:
import boto.dynamodb
conn = boto.dynamodb.connect_to_region(
'eu-west-1',
aws_access_key_id=aws_key,
aws_secret_access_key=aws_secret)
table = conn.get_table('TweetSample')
for row in table.scan(max_results=1):
print row
或将其转换为序列:
print list(table.scan(max_results=1))