本文介绍了dynamodb行数通过python,boto查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,
我试图获取下面的代码来返回表中的行数:
import boto
从boto.dynamodb2.table import boto.dynamodb2
import table
从boto.dynamodb2.fields import HashKey,RangeKey
driver = Table( 'current_fhv_drivers')
rowcountquery = drivers.query(
number ='blah',
expiration ='foo',
count = True,
)
for rowcountquery中的x:
print x ['Count']
我看到的错误是:
boto.dynamodb2.exceptions.UnknownFilterTypeError:无法识别 count中的运算符 count。
获取行数的正确语法是什么:)
谢谢!
解决方案
该异常基本上是在告诉您boto无法识别运算符 count。 / p>
如果您阅读了您会看到:
所以我将代码更改为:
导入boto
导入boto.dynamodb2
从boto.dynamodb2.table import表
从boto .dynamodb2.fields import HashKey,RangeKey
drivers = Table('current_fhv_drivers')
rowcountquery = drivers.query(
number__eq ='blah',
expiration__eq = 'foo',
count__eq = True,
)
for rowcountquery中的x:
print x ['Count']
Folks, Am trying to get the following bit of code working to return the row count in a table:
import boto
import boto.dynamodb2
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey
drivers = Table('current_fhv_drivers')
rowcountquery = drivers.query(
number = 'blah',
expiration = 'foo',
count=True,
)
for x in rowcountquery:
print x['Count']
Error I see is:
boto.dynamodb2.exceptions.UnknownFilterTypeError: Operator 'count' from 'count' is not recognized.
Whats the correct syntaxt to get row count :)
Thanks!
解决方案
That exception is basically telling you that the operator 'count' is not recognized by boto.
If you read the second paragraph on http://boto.readthedocs.org/en/latest/dynamodb2_tut.html#querying you'll see that:
So I would change your code to:
import boto
import boto.dynamodb2
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey
drivers = Table('current_fhv_drivers')
rowcountquery = drivers.query(
number__eq = 'blah',
expiration__eq = 'foo',
count__eq = True,
)
for x in rowcountquery:
print x['Count']
这篇关于dynamodb行数通过python,boto查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!