问题描述
我的应用程序使用。我无法访问模型。
我有我的 bulkloader.yaml
文件由 appcfg.py create_bulkloader_config $自动生成C $ C>。
问题是实体数字ID被导入为字符串键名称。因此,如果我导出具有例如 '62'的int ID的实体,那么它将导入为具有字符串键名称为 '61'的实体,这将拧紧Django。 / p>
Revelant bulkloader.yaml片段:
property_map:
- property:__key__
external_name:key
export_transform:transform.key_id_or_name_as_string
我正在尝试使用bulkloader设置下载/上传od数据,我想要将数据视为易于理解的格式(如.csv)---所以使用 bulkloader.py --dump(...)
不是一个可行的选择,因为它给了我的sqlite3文件,其实体内容被腌制成一行。
编辑
我试着做一些@Nick建议的例子:
ErrorOnTransform:此时不输入数字键。
这是否意味着我必须坚持bulkloader.py(使用该werid sqlite格式)或我搞砸了一些东西;)
变形金刚标题
- kind:auth_user
连接器:csv
connector_options:
encoding:utf-8
skip_import_header_row:True
print_export_header_row:True
property_map:
- 属性:__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)
整个堆栈跟踪:
追溯(最近的最后通话):
/ pre>
文件/opt/google/appengine/google/appengine/tools/adaptive_thread_pool.py,第150行,WorkOnItems
状态,指令= item.PerformWork(self .__ thread_pool)
文件/opt/google/appengine/google/appengine/tools/bulkloader.py,行693,在PerformWork
transfer_time = self._TransferItem(thread_池)
文件/opt/google/appengine/google/appengine/tools/bulkloader.py,第848行,在_TransferItem
self.content = self.request_manager.EncodeContent(self.rows)
文件/opt/google/appengine/google/appengine/tools/bulkloader.py,第1269行,EncodeContent中
entity = loader.create_entity(values,key_name = key,parent = parent)
文件/opt/google/appengine/google/appengine/ext/bulkload/bulkloader_config.py,第385行,在create_entity中
return self.dict_to_entity(input_dict,self.bulkload_state)
文件 /opt/google/appengine/google/appengine/ext/bulkload/bulkloader_config.py,第131行,在dict_to_entity
instance = self .__ create_instance(input_dict,bulkload_state_copy)
文件/ opt / google / appengine / google / appengine / ext / bulkload / bulkloader_config.py,第209行,__create_instance
'此时不输入数字键''
解决方案你有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)
种是配置文件中标识的类型的名称。
My application uses Django non-rel. I don't have access to model.
I have my
bulkloader.yaml
file autogenerated byappcfg.py create_bulkloader_config
.Problem is entities numeric ID's are being imported as string key names. So if I export entity with int ID of, for example, '62', it gets imported as entity with string key name of '61' which screws up Django.
Revelant bulkloader.yaml Fragment:
property_map: - property: __key__ external_name: key export_transform: transform.key_id_or_name_as_string
I'm trying to setup download/upload od data using bulkloader, and I want to have data as easy to understand format (like .csv) --- so using
bulkloader.py --dump (...)
is not a viable option since it gives me sqlite3 files that have entities contents pickled as a single row.EDIT
I tried doing what @Nick suggested and I got an exception:
ErrorOnTransform: Numeric keys are not supported on input at this time.
Does this mean that I have to stick to bulkloader.py (that uses that werid sqlite format) or I messed something? ;)
Header of Transformer:
- 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 Stacktrace:
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.')
解决方案You've got the export_transform 'key_id_or_name_as_string', but you don't have a corresponding import transform. Try this:
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)
Where 'Kind' is the name of the kind identified in the config file.
这篇关于使用yaml自动生成配置和具有数字ID的实体时,Google App Engine批量加载器出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!