AppEngine批量加载器和自动创建的属性值 [英] AppEngine bulk loader and automatically created property values

查看:120
本文介绍了AppEngine批量加载器和自动创建的属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模型中,我有一个属性:

$ p $ created = db.DateTimeProperty(required = True,auto_now_add = True)

在数据存储中创建此类型的对象时,创建的属性自动填充。



当我使用没有此字段的表的批量加载器工具时,当我上传到AppEngine时,字段不会自动填充创建新的对象。



如何设置从批量加载器上传的新对象的创建时间

解决方案

在bulkloader.yaml中添加如下内容:

   - property:created 
external_name:created
import_transform:lambda x:datetime.datetime.utcnow()


In my model I have a property:

created = db.DateTimeProperty(required=True, auto_now_add=True)

When an object of this type is created in the datastore, the created property is automatically populated.

When I use the bulk loader tool with a table which does not have this field, the field is not automatically populated when I upload to AppEngine, at which time new objects are created.

How can I make it set the created time on new objects uploaded from the bulk loader?

解决方案

Add something like the following to bulkloader.yaml:

- property: created
  external_name: created
  import_transform: "lambda x: datetime.datetime.utcnow()"

这篇关于AppEngine批量加载器和自动创建的属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆