2014-04-02 26 views
0

数据填充后端数据存储我下面这个教程中有很多麻烦,它很多地方都没有解释初学者:https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial使用上传脚本

我来到了一部分,我们需要上传一些数据到数据存储。他们正在使用.csv文件来完成该操作。

这是我坚持教程的一部分:

Create Upload Script 

This is the script that actually uploads the simulated information into the backend datastore. 

For information about the bulkloader.yaml and more, refer to the App Engine documentation in: Uploading and Downloading Data. Also, you can find the bulkloader.yaml file and the test data here MobileAssistant-Data. 

Create a new directory and make it your current directory. 
In your editor, create a script file and call it upload_data.sh. 
Copy and paste the following code into the file. 
#!/bin/sh 
appcfg.py upload_data 
--config_file bulkloader.yaml --url=http://localhost:8888/remote_api --filename $1 --kind=$2 -e 
[email protected] 
The previous script accepts two arguments separated by a blank space: 

./upload_data.sh<data.csv> <class entity name> 

The first argument is the name of the csv file that contains the data you want to upload, The second is the name of the entity class to handle the data. 

Close and save the file. Notice that the script at this time is intended to be used on local server. It must be modified when the backend application is deployed to the cloud. For example, e-mail “[email protected] ” will be changed to an actual e-mail address of the App Engine administrator before deployment. 
Places Simulated Data 

The simulated data is contained in the file places.csv that you downloaded earlier from the MobileAssistant-Data directory in Mobile Shopping Assistant. 

The file contains the following comma separated fields: 

name: <place’s name> 
placeId: <number that identifies the place> 
location: <place’s latitude and longitude coordinates (two values separated by a comma) > 
key: <unique key associated with the place> 
address: <the place’s address > 
Modify Web.xml 

To upload data to the datastore, reference the “remote API servlet” and associate it with a URL. You’ll define these mappings in the Web.xml file of the MobileAssistant-Appengine application, as shown next. The web server uses this configuration to identify the servlet to handle a given request. 

Note. Notice, you might need to restart Eclipse. if you skip th e Web.xml modification you will get Error 404 Not Found. 

<servlet> 
<display-name>Remote API Servlet</display-name> 
<servlet-name>RemoteApiServlet</servlet-name> 
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>RemoteApiServlet</servlet-name> 
<url-pattern>/remote_api</url-pattern> 
</servlet-mapping> 
Upload Places Simulated Data 

To upload the test data to the data store, run the script that uploads the data from your script directory. 

Before you upload your data, make sure to start MobileAssistant-AppEngine as a Web Application (in Debug mode) in Eclipse. 

./upload_data.sh <places.csv> Place 
At the password request, just press enter. 

我不明白的脚本的一部分。我在桌面上创建了一个文件夹age,放在他们的文件bulkloader.yamlplaces.csv中。该文件夹内是该上传脚本。

后,我跑./upload_data.sh <places.csv> Place,在我的终端我收到以下错误:

upload_data.sh: line 2: appcfg.py: command not found 
upload_data.sh: line 3: --config_file: command not found 
upload_data.sh: line 4: [email protected]: command not found 

我应该怎么做才能上传数据,谷歌App Engine数据存储?谢谢。

回答

0

在您的路径appcfg.py,如果不是则设置路径明确在你的脚本或appcfg.py添加到您的PATH路径

+0

谢谢你的建议,但我真的不知道我需要什么做。我应该在哪里放脚本以及如何找到appcfg.py?我没有看到我的MAC上的任何地方的文件。 – user3339562

+0

appcfg.py将在您安装google_appengine SDK的地方找到。 –

+0

我安装了Eclipse GAE插件,现在我看到了'appcfg.sh',而不是'appcfg.py'。我将它复制到我的文件夹,但现在我收到一条消息appcfg.sh无法找到。 – user3339562