Sungineer Sungineer - 2 months ago 7
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

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 apiclient.discovery.build function. For eg:

from apiclient.discovery import build


api_root = 'https://<APP_ID>.appspot.com/_ah/api'
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.


EDIT:

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

pip install googledatastore

Trivial example