使用 Google App Engine Bulkloader 生成默认值
我之前已经在我的项目中成功使用了bulkloader,但最近我在修改记录时添加了一个新字段来表示时间戳。不过,这个新字段给我带来了麻烦,因为它默认为空。在导入之前,如果没有在 csv 中手动插入时间戳,有没有办法可以插入当前正确的数据?我认为我需要查看 import_transform 行,但我对 Python 一无所知(我的应用程序是用 Java 编写的)。
理想情况下,我想自动插入当前时间戳(自纪元以来的毫秒数)。如果这很重要,可以在运行导入之前在转换语句中静态设置该值。谢谢。
I have successfully used the bulkloader with my project before, but I recently added a new field to timestamp when the record was modified. This new field is giving me trouble, though, because it's defaulting to null. Short of manually inserting the timestamp in the csv before importing it, is there a way I can insert the current right data? I assume I need to look toward the import_transform line, but I know nothing of Python (my app is in Java).
Ideally, I'd like to insert the current timestamp (milliseconds since epoch) automatically. If that's non-trivial, maybe set the value statically in the transform statement before running the import. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所做的那样,定义自定义转换函数是正确的方法。不过,您不必修改transform.py - 将函数放入您自己的应用程序中的文件中,并将其导入到yaml 文件的python_preamble 中。
Defining a custom conversion function, as you did, is the correct method. You don't have to modify transform.py, though - put the function in a file in your own app, and import it in the yaml file's python_preamble.