开发者

gae bulkloader won't parse key name on import?

in the default bulkloader.yaml it said this:

#    - Check that __key__ property is what you want. Its value will become
#      the key name on import, and on export the value will be the Key
#      object. If you would like automatic key generation on import and
#      omitting the key on export, you can remove the entire __key__
#      property from the property map.

so I assume the default implementation:

- property: __key__
      external_name: key
      export_transform: transform.key_id_or_name_as_string

should import the k开发者_StackOverflow中文版ey column in my csv file into the datastore with no problem. However it appear to do nothing. (other columns were parsed fine though)


You need an import_transform to get the key into the datastore. The export transform is for writing out to the csv file.

I don't think there's a built-in transform method to turn a string back into a key.

I wrote two helper functions for dealing with exporting and importing keys: key_to_reverse_str (export) and reverse_str_to_key (import) The idea was to keep the value human readable on exporting, but keep all data needed for import. They might be useful for you.


I was right on that the default implement was enough. No import_transform was needed. I couldn't parse key value because the first column in the csv file (which contained the keys) could never be parsed no matter which field it contains. Simply place a dummy column as the first column fixed the problem.

@Calvin, sorry I didn't validate your answer sooner.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜