如何从我的Compute Engine VM访问我的AppEngine DataStore实体?

Deb*_*nha 4 google-app-engine app-engine-ndb google-compute-engine google-cloud-datastore

我的应用程序在App Engine上运行,但我想从我的Compute Engine VM访问其NDB DataStore实体来进行一些处理并将结果写回App Engine DataStore.我怎样才能做到这一点?

此外,Google Cloud DataStore和App Engine DataStore是一样的吗? https://developers.google.com/datastore/ https://developers.google.com/appengine/docs/python/ndb/

Dmy*_*hyi 9

David的解决方案要求您使用App Engine实例时间来发出请求,但您可以绕过它并从Compute Engine实例直接向Datastore发出请求.关于如何做到这一点有一个非常好的教程.但它不像ndb那么漂亮.

>>> import googledatastore as datastore
>>> datastore.set_options(dataset='project-id')
>>> req = datastore.BeginTransactionRequest()
>>> datastore.begin_transaction(req)
<datastore.datastore_v1_pb2.BeginTransactionResponse object at ...>
Run Code Online (Sandbox Code Playgroud)

  • "用于从计算引擎访问现有App Engine数据存储的Google Cloud数据存储":https://developers.google.com/datastore/docs/activate#google_cloud_datastore_for_accessing_an_existing_app_engine_datastore_from_compute_engine (8认同)