问题描述
我可以上传数据,但key_name为空。
如何使用中的'id'作为key_name数据存储区?
我喜欢使用 id作为键名,因为其他数据使用 id作为外键。
我是Google App Engine的新手。
这是CSV数据。
id,名称
1,美国
2,法国
3,意大利
这是
-模型:model.testcountry.TestCountry
连接器:csv
connector_options:
编码:utf-8
列:from_header
property_map:
-属性:__key__
external_name:id
-属性:name
external_name:名称
PS:我正在尝试将数据上传到本地环境。 / p>
更新
谢谢为了获得帮助,我尝试了代码,但效果不佳。
结果很奇怪。
在终端窗口中,一条日志消息告诉我上传成功完成,但是
却找不到。 Google App Engine控制台(http:// localhost:8080 / _ah / admin / datastore)。数据存储区为空,没有任何记录。
终端窗口中的日志消息是
输入命令
appcfg.py upload_data --config_file = bulkloader.yaml --filename = testcountries.csv --kind = TestCountry --url = http:// localhost:8080 / remote_api --num_thread = 1
结果消息
上传数据记录。
[INFO]登录到bulkloader / log.log
[INFO]节流传输:
[INFO]带宽:250000字节/秒
[INFO] HTTP连接:8 /秒
[INFO]插入/获取/修改的实体:20 /秒
[INFO]批处理大小:10
请输入本地主机的登录凭据:8080
电子邮件:xxxxxxx
l的密码:
[INFO]打开数据库:bulkloader-progress-20110609.003032.sql3
[INFO]连接到本地主机:8080 / remote_api
[INFO]开始导入;每个帖子中最多10个实体
.....
[INFO]总共100个实体,以前传输了0个实体
[INFO]在1.9秒内传输了100个实体(3362字节)
[INFO]所有实体都成功转移了
我也尝试过此操作,但是结果是相同的。终端显示成功,但是在Google App Engine控制台中没有记录...。
import_transform:int
PS:我使用的是Mac OS X Snow Leopard和Google App Engine启动器。
尝试一下:
-导入: google.appengine.ext.bulkload.transform
-模型:model.testcountry.TestCountry
连接器:csv
connector_options:
编码:utf-8
列:from_header
property_map:
-属性:__key__
external_name:id
import_transform:transform.create_foreign_key('TestCountry')
-属性:name
external_name:name
I can upload data, but key_name is empty.How can I use the 'id' in the CSV as the key_name on datastore?
I'like to use 'id' as the key_name, because other data uses the 'id' as the foreign key.I'm new to Google App Engine.
This is the CSV data.
"id","name"
"1","USA"
"2","France"
"3","Italy"
This is the YAML
- model: model.testcountry.TestCountry
connector: csv
connector_options:
encoding: utf-8
columns: from_header
property_map:
- property: __key__
external_name: id
- property: name
external_name: name
P.S: I'm trying upload data to the local enviroment.
Update
Thank you for the help, I tried the code, but it does not work well.The result is strange.
In the terminal window a log message tells me that uploading finished successfully,however I cannot find any records in the Google App Engine console (http://localhost:8080/_ah/admin/datastore). The datastore is empty, there is no record.
The log message in the terminal window is this
Entering command
appcfg.py upload_data --config_file=bulkloader.yaml --filename=testcountries.csv --kind=TestCountry --url=http://localhost:8080/remote_api --num_thread=1
Result message
Uploading data records.
[INFO ] Logging to bulkloader/log.log
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 250000 bytes/second
[INFO ] HTTP connections: 8/second
[INFO ] Entities inserted/fetched/modified: 20/second
[INFO ] Batch Size: 10
Please enter login credentials for localhost:8080
Email: xxxxxxx
Password for l:
[INFO ] Opening database: bulkloader-progress-20110609.003032.sql3
[INFO ] Connecting to localhost:8080/remote_api
[INFO ] Starting import; maximum 10 entities per post
..........
[INFO ] 100 entities total, 0 previously transferred
[INFO ] 100 entities (3362 bytes) transferred in 1.9 seconds
[INFO ] All entities successfully transferred
I also tried this, but result was same. The terminal says success but in the Google App Engine console there are no records....
import_transform: int
PS: I'm using Mac OS X Snow Leopard and Google App Engine launcher.
Try this:
- import: google.appengine.ext.bulkload.transform
- model: model.testcountry.TestCountry
connector: csv
connector_options:
encoding: utf-8
columns: from_header
property_map:
- property: __key__
external_name: id
import_transform: transform.create_foreign_key('TestCountry')
- property: name
external_name: name
这篇关于如何通过Google App Engine批量加载器使用key_name上传数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!