我正在使用pynamodb==3.3.3扫描符合attributes_to_get条件的项目,但得到一个我无法解决的异常:
File "/Users/user/Documents/project/script.py", line 250, in filter_writable_snapshots
existing_snapshots = ItemSnapshot.scan(attributes_to_get=['id'])
File "/Users/user/Documents/project/venv/lib/python3.7/site-packages/pynamodb/models.py", line 790, in scan
filters=filters
File "/Users/users/Documents/project/venv/lib/python3.7/site-packages/pynamodb/models.py", line 1050, in _build_filters
raise ValueError("Attribute {0} specified for filter does not exist.".format(attr_name))
ValueError: Attribute attributes_to_get specified for filter does not exist.该模型有一个字段id。
from pynamodb.models import Model
from pynamodb.attributes import UnicodeAttribute
class ItemSnapshot(Model):
class Meta:
table_name = 'my_table'
id = UnicodeAttribute(hash_key=True)
other_field = UnicodeAttribute()我正在尝试只加载id字段。
existing_snapshots = ItemSnapshot.scan(attributes_to_get=['id'])我是不是做错了什么,或者为什么请求崩溃了?strack跟踪看起来会试图找到属性attributes_to_get,这对我来说没有任何意义。
我已经检查了类的属性id does exist。
发布于 2019-06-14 16:36:40
方法.scan()没有参数attributes_to_get。这在.query()和.rate_limited_scan()方法上可用。
https://stackoverflow.com/questions/56498936
复制相似问题