Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python NDB查询返回零结果。数据存储显示结果_Python_Google App Engine_Google Cloud Datastore_App Engine Ndb - Fatal编程技术网

Python NDB查询返回零结果。数据存储显示结果

Python NDB查询返回零结果。数据存储显示结果,python,google-app-engine,google-cloud-datastore,app-engine-ndb,Python,Google App Engine,Google Cloud Datastore,App Engine Ndb,我发现了一个特殊的问题,即运行查询,确认记录存在,返回的计数为零 以下是我的模型: class Description(ndb.Model): description = ndb.TextProperty() time_posted = ndb.DateTimeProperty(auto_now_add=True) uuid = ndb.StringProperty() class Examine(ndb.Model): updated = ndb.DateTi

我发现了一个特殊的问题,即运行查询,确认记录存在,返回的计数为零

以下是我的模型:

class Description(ndb.Model):
    description = ndb.TextProperty()
    time_posted = ndb.DateTimeProperty(auto_now_add=True)
    uuid = ndb.StringProperty()

class Examine(ndb.Model):
    updated = ndb.DateTimeProperty(auto_now=True, auto_now_add=True)
    descriptions = ndb.StructuredProperty(Description, repeated=True)
    active = ndb.KeyProperty(kind=Description)
    slug = ndb.StringProperty(indexed=True)
假设我正在运行以下命令,确认数据存储中确实存在特定的UUID:

d_id = 'ef531b70-3486-11e3-9500-ef31d661e6b2'
cnt = Description.query(Description.uuid == d_id).count()

我将收到0作为cnt的结果。有人能解释一下为什么会发生这种情况吗?

数据存储查询最终是一致的。这意味着,如果基础数据发生更改,有时查询将无法反映此更改

要解决此问题,您可以将数据存储和查询的结构设置为强一致性:

如果描述实体保存在检查的父项中,则以下查询将非常一致:

cnt = Description.query(ancestor=ExamineKey).filter(Description.uuid == d_id).count()