Sungineer Sungineer - 1 year ago 92
Python Question

how to access google datastore from an installed application on PC written in Python?

I have some entities added on datastore - made a little web app (in Python) to read and write from the datastore through endpoints. I am able to use the webapp through endpoints from javascript.
I want to access the web app from an installed application on PC. Is there a way to access endpoints from installed applications written in Python? How?

Is there any other way to access the datastore from PC installed applications written in Python?

Answer Source

That's one of the beauties of AppEngine's endpoints. You should use the Python Client Library for Google's APIs to communicate with your endpoints

pip install --upgrade google-api-python-client

Then you'll construct a resource object to communicate with your api using the function. For eg:

from apiclient.discovery import build

api_root = 'https://<APP_ID>'
api = 'api_name'
version = 'api_version'
discovery_url = '%s/discovery/v1/apis/%s/%s/rest' % (api_root, api, version)
service = build(api, version, discoveryServiceUrl=discovery_url)

You can then perform operations at service.<endpoint_method> etc

A more complete example with authentication can be found here.


Or as @Zig recommends, directly use the Google Cloud API

pip install googledatastore

Trivial example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download