【问题标题】:sqlite datastore and index.yamlsqlite 数据存储和 index.yaml
【发布时间】:2011-08-16 05:48:14
【问题描述】:

我正在从基于文件的原始数据存储迁移到 sqlite 版本。

我有一个命令行脚本,它按如下方式初始化存根:

from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore.datastore_sqlite_stub import DatastoreSqliteStub

apiproxy_stub_map.apiproxy=apiproxy_stub_map.APIProxyStubMap()
apiproxy_stub_map.apiproxy.RegisterStub("datastore_v3", DatastoreSqliteStub("myapp", Datastore, "/"))

查询数据存储会引发 NeedIndexError;然而——

  • 相关的索引定义在 index.yaml 中让我眼前一亮
  • 访问旧的基于文件的数据存储没有问题 [使用 DatastoreFileStub]

我是否以某种方式无法使用 index.yaml 初始化数据存储区?

【问题讨论】:

    标签: google-app-engine google-cloud-datastore


    【解决方案1】:

    DatastoreSqliteStub 的构造函数参数是:

               app_id,
               datastore_file,
               require_indexes=False,
               verbose=False,
               service_name='datastore_v3',
               trusted=False,
               consistency_policy=None
    

    通过提供这些命名参数,您可以(正确地)指定应用 ID、您指定的数据存储文件是某个名为 Datastore 的对象,以及是否需要索引(您已设置到 '/',其计算结果为 True)。相反,只需指定第一个和第三个参数。

    【讨论】:

    • 超级 - 谢谢 - 我猜是 RTFM。我只是不假思索地从 DatastoreFileStub 复制了参数。 AppEngine 摇滚 BTW,尤其是任务队列 - 继续努力!
    猜你喜欢
    • 1970-01-01
    • 2022-08-12
    • 2011-12-30
    • 2014-05-19
    • 1970-01-01
    • 2021-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多