AWS Boto: scan() unknown keyword 'limit'

1k Views Asked by At

Anyone come across this before?

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)

error:

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]

I don't even know...

1

There are 1 best solutions below

0
falsetru On BEST ANSWER

According to the documentation, scan method of boto.dynamodb.table.Table (which is returned by boto.dynamodb.layer2.Layer2.get_table) does not accepts limit, but max_results.

And the result is a generator. So, if you want to print it you should iterate it:

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

or convert it to a sequence:

print list(table.scan(max_results=1))