1
votes

I am trying to run multiple Google App Engine's Datastore from my local machine in Python.

UPDATED My problem is this: When i run project-A on GAE locally. It is working fine. But When run project-B the datastore of project-A are alerady gone So, how can i run multiple GAE project locally.

2
What do you mean with "deploy multiple GAE project locally"? Deploying is when you 'upload' the project to GAE, but locally means that you run it in your machine. Which are you referring to?amport
Sorry. i was wrong. I updated the question.Min Min

2 Answers

1
votes

To run different applications locally with independent datastore, you need to execute dev_appserver.py in different terminal sessions.

In each execution you need to specify different --admin_port, --port, and --storage_path flags so both apps can run independent to one another.

Example:

Session 1 $ dev_appserver.py <location1-to-app.yaml>/app.yaml
--admin_port=<ADMIN_PORT1> --port=<PORT1> --storage_path=<Path1> 

Sesison 2 $ dev_appserver.py <location2-to-app.yaml>/app.yaml
--admin_port=<ADMIN_PORT2> --port=<PORT2> --storage_path=<Path2>

This will create different datastore files in each path.

Here’s information about dev_appserver.py flags you may find useful.

0
votes

You need to explicitly specify projectId on datastore connection object creation.

Example in nodejs:

Project-A

const db = new Datastore({
    projectId: "google-project-A-id"
});

Project-B

const db = new Datastore({
    projectId: "google-project-B-id"
});

You can setup this via configs, so you will not need to hardcode it. In this case each datastore connection in application will always point to specific project's datastore instance.

See how to pass projectId into Datastore class for your language in documentation.