Synt4x
Synt4x

Reputation: 41

Can you use GQL / Google DataStore outside of google appengine?

Can I use GQl/DataStore in my local python app? I know I can use them locally when running the dev_appserver.py when writing a webapp but now I don't want to do anything web related and keep it all local with just my normal pythonfile.py with no HTML interfacing. Is it possible to do this?

Upvotes: 1

Views: 171

Answers (2)

Dan McGrath
Dan McGrath

Reputation: 42048

Yes, Cloud Datastore can be accessed via client libraries outside of App Engine. They run on the v1 API which just went GA (August 16, 2016) after a few years in Beta.

The Client Libraries are available for Python, Java, Go, Node.js, Ruby, and there is even .NET.

You should be aware that the GQL language variant supported in NDB is a little different from what the Cloud Datastore service itself supports. The NDB Client Library does some of it's own custom parsing that can split certain queries into multiple ones to send to the service, combining the results client-side.

Take a read of our GQL reference docs.

Upvotes: 0

jqualls
jqualls

Reputation: 1503

The Remote API can also be used within local applications. This will allow you to write local applications that use App Engine services and access datastore. It is important to note that using the Remote API will incur quota usage on the application you are accessing.

Before beginning, make sure the App Engine SDK is added to your Python path and Remote API is enabled in your App Engine application. The following example shows the use of OAuth 2.0 credentials to configure the Remote API:

from google.appengine.ext.remote_api import remote_api_stub
from helloworld import helloworld

remote_api_stub.ConfigureRemoteApiForOAuth('your_app_id.appspot.com',
                                           '/_ah/remote_api')

# Fetch the most recent 10 guestbook entries
entries = helloworld.Greeting.all().order("-date").fetch(10)
# Create our own guestbook entry
helloworld.Greeting(content="A greeting").put()

Reference: https://cloud.google.com/appengine/docs/python/tools/remoteapi

Upvotes: 1

Related Questions