GAE: AssertionError: No api proxy found for service "datastore_v3"
Asked Answered
C

1

3

I'm writing simple to code to access dev server. Both dev server and datastore emulated have been started locally.

from google.appengine.ext import ndb

class Account(ndb.Model):
    name = ndb.StringProperty()

acc = Account(name=u"test").put()
print(acc)

Error:

AssertionError: No api proxy found for service "datastore_v3"

I tried to set: export DATASTORE_EMULATOR_HOST=localhost:8760 . It does not help.

$ dev_appserver.py  ./app.yaml 
WARNING  2017-02-20 06:40:23,130 application_configuration.py:176] The "python" runtime specified in "./app.yaml" is not supported - the "python27" runtime will be used instead. A description of the differences between the two can be found here:
https://developers.google.com/appengine/docs/python/python25/diff27
INFO     2017-02-20 06:40:23,131 devappserver2.py:764] Skipping SDK update check.
INFO     2017-02-20 06:40:23,508 api_server.py:268] Starting API server at: http://localhost:53755
INFO     2017-02-20 06:40:23,514 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-02-20 06:40:23,517 admin_server.py:116] Starting admin server at: http://localhost:8000
Chrischrism answered 20/2, 2017 at 6:47 Comment(0)
C
4

GAE app code cannot run as a standalone python app, it can only run inside a GAE app which runs inside your dev server. Typically as part of a handler code, triggered via http requests to the dev server.

You need to put that code inside one of your app handlers. For example inside the get() method of the MainPage handler from main.py in the Quickstart for Python App Engine Standard Environment (actually it'd be better in a post() method since your code is writing to the datastore).

Carnay answered 20/2, 2017 at 15:1 Comment(2)
Is there a way to manipulate datastore using standalone scripts? I have large dataset in mongodb locally. I need to port it to local datastore emulator, check data integrity, then upload to cloud datastore. It'll be better if I can reuse the ndb models.Chrischrism
Not using ndb, which is only available inside GAE apps. But yes, see cloud.google.com/datastore/docs/reference/libraries.Carnay

© 2022 - 2024 — McMap. All rights reserved.