我一直在玩appengine,但我似乎误解了NDB数据存储查询。 我将抛出的错误放在查询旁边。你知道吗
在交互式控制台中播放:
from google.appengine.ext import ndb
class Client(ndb.Model):
email = ndb.StringProperty()
name = ndb.StringProperty(indexed=True)
#instantiated client instance with the parameters below. ID is 6578378068983808
#client = Client(email = "bryan@gmail.com", name = "Bryan Wheelock" ).put()
client = Client.query( Client.name == 'Bryan Wheelock')
#client = Client.query( Client.ID == 6578378068983808 ) #AttributeError: type object 'Client' has no attribute 'ID'
#client = Client.all() #AttributeError: type object 'Client' has no attribute 'all'
#client = Client.get_by_id(6578378068983808) #THIS WORKS returns u'Bryan Wheelock'
pprint.pprint(client.name)
我所做的示例查询来自appengine文档,我做错了什么?你知道吗
查询
你知道吗客户端.query()返回查询对象。你知道吗
你需要像这样得到结果:
或者只是:
身份证
id不是模型的属性,而是它的键的属性。要通过其id直接获取客户机,您可以
为了便于参考,您可以在这里查找Model方法:https://cloud.google.com/appengine/docs/python/ndb/modelclass
相关问题 更多 >
编程相关推荐