GAE NDB Datastore new feature: Access Datastore entities from other GAE app

南楼画角 提交于 2019-12-03 00:08:22

Currently, ndb doesn't use the Cloud Datastore API and in its normal mode of operation can't connect to another app's Datastore - it connects natively to the Datastore of the app the code is running on.

You can, however, use the remote api to have ndb connect to the Datastores of different apps from the development environment.

There is currently [an open Feature Request in the Public Issue Tracker for App Engine for the possibility of accessing multiple Datastores from a single app. Feel free to post a Feature Request for ndb specifically, although from the following comments in the source it appears this is already something that's being worked-on:

 current_app_id = os.environ.get('APPLICATION_ID', None)
  if current_app_id and current_app_id != app_id:
    # TODO(pcostello): We should support this so users can connect to different
    # applications.
    raise ValueError('Cannot create a Cloud Datastore context that connects '
                     'to an application (%s) that differs from the application '
                     'already connected to (%s).' % (app_id, current_app_id))
  os.environ['APPLICATION_ID'] = app_id
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!