1

任何人都遇到過這個?AWS Boto:掃描()未知關鍵字'限制'

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

根據(由boto.dynamodb.layer2.Layer2.get_table返回)的文件中,boto.dynamodb.table.Tablescan method不接受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))