1

私はdevサーバーにアクセスするための簡単なコードを書いています。エミュレートされたdevサーバーとデータストアの両方がローカルで開始されています。GAE:AssertionError:サービス "datastore_v3"のapiプロキシが見つかりません

from google.appengine.ext import ndb 

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

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

エラー:export DATASTORE_EMULATOR_HOST=localhost:8760を:

AssertionError: No api proxy found for service "datastore_v3" 

私が設定してみました。それは助けにはならない。

$ 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 

答えて

2

GAEアプリのコードは、それだけであなたのdevのサーバー内で実行さGAEアプリ内を実行することができ、スタンドアロン Pythonアプリケーションとして実行することはできません。通常、ハンドラコードの一部として、devサーバへのHTTPリクエストを介してトリガされます。

あなたのアプリケーションハンドラの1つにそのコードを入れる必要があります。例えば、のMainPageハンドラの中でmain.pyからQuickstart for Python App Engine Standard Environmentまでです(コードはデータストアに書き込んでいるので実際はpost()の方が良いでしょう)。

+0

スタンドアロンスクリプトを使用してデータストアを操作する方法はありますか?私はmongodbに大きなデータセットをローカルに持っています。私はそれをローカルのデータストアエミュレータに移植し、データの整合性をチェックしてから、クラウドデータストアにアップロードする必要があります。 ndbモデルを再利用できるといいでしょう。 –

+0

GAEアプリケーション内でのみ利用可能な 'ndb'を使用していません。しかし、はい、https://cloud.google.com/datastore/docs/reference/librariesをご覧ください。 –

関連する問題