How do I get live data from my production App Engine app to my local dev app?

帅比萌擦擦* 提交于 2019-12-04 23:47:11

问题


I'd like to know if anyone has pointers about how to configure AppEngine remote_api, to so that I can debug my code locally but use the remote_api to fetch some data from my server. That way, I can test against real information.

Thanks!


回答1:


If you want to debug your own script with using data from High Replication Datastore, then read Using the Remote API in a Local Client. First you need to enable remote_api in app.yaml and upload the application. Then you add this part to your script:

from google.appengine.ext.remote_api import remote_api_stub

def auth_func():
   return ('your_username', 'your_password')

remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func, 'your-app-id.appspot.com')

Now you access data from High Replication Datastore instead from local mockup.

Also if you want to quickly add test data to HRD through console I recommend using PyCharm, which has a feature of running scripts with custom parameters. From PyCharm Menu select Run->Edit Configurations. Create new configuration, set the following parameters:

  • Name: Name of the script
  • Script: Point to your $GAE_SDK_ROOT\remote_api_shell.py
  • Script parametres: -s your_app_id.appspot.com
  • Working directory: I recommend setting this. You probably want to test entities and to successfully import class definitions it is best to be in root directory of your application. So set it to ROOT of your application.

Now when you run or debug specified configuration PyCharm will open a python console, prompting you to connect to GAE with your username and password. Now you can use it for manipulating data on Google servers.

For more information on remote_api read:

  • Accessing the datastore remotely with remote_api
  • Remote API for Python

For more information on Pycharm custom configurations, read:

  • Creating and Editing Run/Debug Configurations



回答2:


You could download data as described here, and use it to populate your local dev app. There's no reason that PyCharm needs to be involved.



来源:https://stackoverflow.com/questions/12377134/how-do-i-get-live-data-from-my-production-app-engine-app-to-my-local-dev-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!