问题描述
我在Google App Engine for Python中部署了一个现有网站。现在我已经在我的系统中安装了本地开发服务器。但我不知道如何从实时服务器获取更新的数据库。 Google开发者控制台中没有导出选项。
而且,我不想从Production Datastore读取每个请求的数据,我想在本地设置它一次。谷歌手册说,它存储本地数据存储在sqlite文件中。
任何提示将不胜感激。
您可能需要在您的Google帐户页面上为此使用生成应用程序专用密码。然后,一般使用情况如下所示:
/usr/local/google_appengine/bulkloader.py --dump --url = http://your_app.appspot.com/_ah/remote_api --filename = allkinds.sq3
您可能还没有能够使用这种所有类型查询 - 服务器只会周期性地为所有种类的查询生成所需的统计信息,因此您可能会收到包含以下信息的错误消息:
[错误]无法下载所有种类下载的kind数据。
[错误]类型统计信息由appserver
定期生成[错误]种类统计信息在dev_appserver上不可用。
如果是这种情况,那么您仍然可以通过将一次一种选项 - kind = EntityKind 并为每种实体重复运行bulkloader(使用单独的sqlite3结果文件)。
一旦你倾销了(如果必要的话,如果你需要的话,如果可能的话,一次完成)生产数据存储,你可以再次使用bulkloader,这次使用 - restore $ b $
它应该可以明确地列出 - kind flag(用逗号分隔它们并将它们全部放在圆括号中),但不幸的是我觉得我发现了一个阻止工作的bug - 我会尝试获取它固定但不屏住呼吸。在任何情况下,这个特性都没有记录(我刚刚通过研究 bulkloader.py 的开源版本发现它),所以最好不要依赖它! - )
有关随后新增的bulkloader的更多信息可以在Nick Johnson的博客文章中找到(尽管它没有覆盖了更新的功能,例如上面概述的零配置方法中的sqlite3格式结果)。还有一个演示,有很多链接,在(也是一个有点过时了,唉)。
I have a existing Website deployed in Google App Engine for Python. Now I have setup the local development server in my System. But I don't know how to get the updated DataBase from live server. There is no Export option in Google's developer console.
And, I don't want to read the data for each request from Production Datastore, I want to set it up locally for once. The google manual says that it stores the local datastore in sqlite file.
Any hint would be appreciated.
First, make sure your app.yaml enables the "remote" built-in, with a stanza such as:
builtins: - remote_api: on
This app.yaml of course must be the one deployed to your appspot.com (or whatever) "production" GAE app.
Then, it's a job for /usr/local/google_appengine/bulkloader.py or wherever you may have installed the bulkloader component. Run it with -h to get a list of the many, many options you can pass.
You may need to generate an application-specific password for this use on your google accounts page. Then, the general use will be something like:
/usr/local/google_appengine/bulkloader.py --dump --url=http://your_app.appspot.com/_ah/remote_api --filename=allkinds.sq3
You may not (yet) be able to use this "all kinds" query -- the server only generates the needed statistics for the all-kinds query "periodically", so you may get an error message including info such as:
[ERROR ] Unable to download kind stats for all-kinds download. [ERROR ] Kind stats are generated periodically by the appserver [ERROR ] Kind stats are not available on dev_appserver.
If that's the case, then you can still get things "one kind at a time" by adding the option --kind=EntityKind and running the bulkloader repeatedly (with separate sqlite3 result files) for each kind of entity.
Once you've dumped (kind by kind if you have to, all at once if you can) the production datastore, you can use the bulkloader again, this time with --restore and addressing your localhost dev_appserver instance, to rebuild the latter's datastore.
It should be possible to explicitly list kinds in the --kind flag (by separating them with commas and putting them all in parentheses) but unfortunately I think I've found a bug stopping that from working -- I'll try to get it fixed but don't hold your breath. In any case, this feature is not documented (I just found it by studying the open-source release of bulkloader.py) so it may be best not to rely on it!-)
More info about the then-new bulkloader can be found in a blog post by Nick Johnson at http://blog.notdot.net/2010/04/Using-the-new-bulkloader (though it doesn't cover newer functionalities such as the sqlite3 format of results in the "zero configuration" approach I outlined above). There's also a demo, with plenty of links, at http://bulkloadersample.appspot.com/ (also a bit outdated, alas).
这篇关于如何从本地开发服务器访问Production Datastore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!