2014-04-02 25 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