开发者

(Google App Engine) Bulkloader upload generates new entries instead of updating existing ones

for my project I am using GAE datastore to store data. For backup purpose I decided to use the bulkloader - which downloads the whole data perfectly in a csv file. Also the upload uploads the data fine without errors.

My problem is, that the upload do not update the existing data but creates duplicates. Here an example from the datastore viewer:

Before update:

ID/Name 
id=18000
id=20001 

After update:

ID/Name
id=18000
id=20001
name=18000
name=20001 

In the datastore entity I am using this as an data id:

@PrimaryKey 
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
private Long id; 

Any Idea how I can开发者_JAVA技巧 actually update existing data with bulkloader?

Thanks, Adam


bulkloader's default settings have a nasty habit of stomping the types of values. This is especially a problem for keys and lists.

I use these helper functions bulk_helper, and add this to my bulkloader.yaml:

python_preamble:
- import: bulk_helper
...

property_map:
  - property: __key__
    external_name: key
    import_transform: bulk_helper.reverse_str_to_key
    export_transform: bulk_helper.key_to_reverse_str

This preserves the full key, including kind and parent info, and keeps it human readable (if that's important to you).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜