Google App Engine bulk loader issue when using automatic generation of yaml and numbered objects

My application uses Django non-rel . I do not have access to the model.

I have a file bulkloader.yamlthat is auto generated appcfg.py create_bulkloader_config.

The problem is that numeric entity identifiers are imported as string key names. Therefore, if I export an object with an identifier int, for example, "62", it is imported as an object with the name of the string key "61", which twists Django.

Revelant bulkloader.yaml Snippet:

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

I am trying to configure data loading / unloading using bulkloader, and I want the data to be easily understood in a format (e.g. .csv) --- therefore use is bulkloader.py --dump (...)not a viable option as it gives me sqlite3 files containing the contents of objects pickled like one line.

EDIT

I tried to do what @Nick suggested, and I got an exception:

 ErrorOnTransform: Numeric keys are not supported on input at this time.

Does this mean that I should stick with bulkloader.py (which uses this werid sqlite format), or have I messed up something ?;)

Transformer Header:

- kind: auth_user
    connector: csv
    connector_options:
      encoding: utf-8
      skip_import_header_row: True
      print_export_header_row: True

    property_map:
      - property: __key__
        external_name: key
        export_transform: transform.key_id_or_name_as_string
        import_transform: transform.create_foreign_key('auth_user', key_is_id=True) 

Whole stack:

      Traceback (most recent call last):
      File "/opt/google/appengine/google/appengine/tools/adaptive_thread_pool.py", line 150, in WorkOnItems
        status, instruction = item.PerformWork(self.__thread_pool)
      File "/opt/google/appengine/google/appengine/tools/bulkloader.py", line 693, in PerformWork
        transfer_time = self._TransferItem(thread_pool)
      File "/opt/google/appengine/google/appengine/tools/bulkloader.py", line 848, in _TransferItem
        self.content = self.request_manager.EncodeContent(self.rows)
      File "/opt/google/appengine/google/appengine/tools/bulkloader.py", line 1269, in EncodeContent
        entity = loader.create_entity(values, key_name=key, parent=parent)
      File "/opt/google/appengine/google/appengine/ext/bulkload/bulkloader_config.py", line 385, in create_entity
        return self.dict_to_entity(input_dict, self.bulkload_state)
      File "/opt/google/appengine/google/appengine/ext/bulkload/bulkloader_config.py", line 131, in dict_to_entity
        instance = self.__create_instance(input_dict, bulkload_state_copy)
      File "/opt/google/appengine/google/appengine/ext/bulkload/bulkloader_config.py", line 209, in __create_instance
        'Numeric keys are not supported on input at this time.')
+5
source share
2 answers

export_transform 'key_id_or_name_as_string', . :

property_map:
 - property: __key__
   external_name: key
   export_transform: transform.key_id_or_name_as_string
   import_transform: transform.create_foreign_key('Kind', key_is_id=True)

"" - , .

+6

:

import_transform: transform.none_if_empty(long)
+2

All Articles