GAE 更改本地对象存储中的数据
我一直在 eclipse 中使用 GAE 开发一个应用程序,并且我有一堆数据对象。有时我需要更改它们的类型,即 String
-> Text
,以便它们可以存储更多数据。
对数据/对象存储进行批量更新的最快最简单的方法是什么?我知道我可以编写 Java 代码来迭代每个对象,但肯定有更简单的方法吗?
I have been working on an application using GAE in eclipse and I have a bunch of data objects. Sometimes I need to change their type, ie String
-> Text
so they can store more data.
What is the quickest easiest way to do a bulk update on the data/object store? I know I could probably write Java code to iterate over each object, but surely there is an easier way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,除了迭代存储并手动更改数据之外,没有其他方法。无法以其他方式访问数据存储。然而,从 SDK 1.3.3 版本开始,现在可以使用 SQLite 作为数据存储后端。要启用,请设置标志 --use_sqlite=true
然后您需要找到 SQLite 文件,并且应该能够使用任何 SQLite 客户端来操作数据。
更新:正如 Nick Johnson 所指出的,SQLite 支持仅适用于 Python SDK,并且数据是经过编码的,这使得根据更改直接编辑表内容的任务相当困难。鉴于发帖者正在寻找一个简单的、基于 Java 的解决方案,这使得这个答案无效:/
Normally there is no other way than iterating the store and changing the data by hand. The datastore is not otherwise accessible. However starting from version 1.3.3 of the SDK there is now the possibility to use SQLite as the datastore backend. To enable, set the flag --use_sqlite=true
You'll need then to find the SQLite file and should be able to use any SQLite client to manipulate the data.
UPDATE: As Nick Johnson noted, SQLite support is only available for the Python SDK and the data is encoded, making the task of directly editing the tables content rather difficult depending on the change. This invalidates this answer given the poster is looking for an easy, Java based solution :/
最佳选择是新发布的 appengine-mapreduce 库,它同时具有Java 和 Python 版本。
不过,在从字符串转换为文本的情况下,无需手动检查和更新旧实体 - 它们将在您的应用程序下次编写时修复,并且在此期间仍然可以正常工作。
The best option for this is the newly released appengine-mapreduce library, which has both Java and Python versions.
In the case of converting from String to Text, though, there's no need to go through and update old entities manually - they'll be fixed when they're next written by your app, and will still work correctly in the meantime.