![](/img/trans.png)
[英]Datastore NDB best practices when querying and extracting thousands of rows
[英]Querying datastore with NDB
我正在尝试使用Python和NDB访问数据存储,其中包含一个实体:
我已经用以下代码由NDB模型定义:
class Test(ndb.Model):
name = ndb.StringProperty()
val = ndb.IntegerProperty()
然后我对实体运行查询:
query = Test.get_by_id("Testing")
这将返回没有val
字段的NoneType
。 我尝试将参数设置为name=Testing
而不是Testing
,但这无济于事。
如何使用Python访问我的实体? 我是否需要在某处标识项目的ID?
另外,我一直在使用Flask作为微框架。 但是我见过的所有NDB示例代码都使用webapp2。 我应该改用webapp2吗?
大写在Python中很重要。 您需要从模型“ test”中查询而不是“ Test”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.