As Python 2 came to an end and App Engine 1 is no longer supported, we are migrating to App Engine 2. I have a sizable Datastore. Given that the two App Engines need to be on two different projects, is it possible to connect to the old App Engine's datastore as the new App Engines's datastore? Ideally using NDB.

- 20,502
- 7
- 59
- 82

- 967
- 2
- 17
- 31
-
1`Given that the two App Engines need to be on two different projects` -- I'm pretty sure that is not the case. See point 3 [here](https://gaedevs.com/blog/things-to-understand-before-migrating-your-python-2-gae-app-to-python-3). – new name Jan 24 '20 at 12:37
-
Thanks @gaefan. Didn't know that. – maininformer Jan 24 '20 at 23:42
1 Answers
The datastore of a GAE/GCP project can be accessed from an app in another project or even from outside Google Cloud, see How do I use Google datastore for my web app which is NOT hosted in google app engine?.
I didn't yet play with the python 3 ndb library (aka Cloud NDB), I can't exactly say if/how it can use another project's credentials. I'm unsure if you want to try to use it, though: from Migrating to Cloud NDB:
Cloud NDB is intended to replace the features in App Engine NDB, so it will not support new features of Firestore in Datastore mode. New Python 3 apps should use the Datastore mode client library instead of Cloud NDB.
In the worst case the Datastore mode client library (actually the recommended one for python 3 GAE apps) should be able to access your python 2 app's datastore - it is generic, it can be used for any app, not just GAE. According to the docs its Client()
method supports specifying a project and credentials (where you'd be using the service account for the python 2 app's project). Potentially of interest: GCP-The App Engine APIs are not available, with py 3

- 39,470
- 12
- 57
- 97
-
Thank you Dan; I also just checked and tried and ndb will also work with the same explicit authentication: https://github.com/googleapis/python-ndb/blob/master/google/cloud/ndb/client.py#L64 which is https://github.com/googleapis/google-cloud-python/blob/2beaa95214d8f5cb18c5d57fb6f8ed2fd326741f/core/google/cloud/client.py#L196 which inherits from: https://github.com/googleapis/google-cloud-python/blob/2beaa95214d8f5cb18c5d57fb6f8ed2fd326741f/core/google/cloud/client.py#L40-L51 – maininformer Jan 24 '20 at 23:33