-
Notifications
You must be signed in to change notification settings - Fork 0
Local Datastore Setup
Wesley Jones edited this page Sep 24, 2021
·
1 revision
You will need to start your emulator with the following command:
gcloud beta emulators datastore start --data-dir=. --project test --host-port "localhost:8001"
Use the following code in main.py:
import os
if os.getenv('GAE_ENV', '').startswith('standard'):
# production
datastore_client = datastore.Client()
else:
os.environ["DATASTORE_DATASET"] = "test"
os.environ["DATASTORE_EMULATOR_HOST"] = "localhost:8001"
os.environ["DATASTORE_EMULATOR_HOST_PATH"] = "localhost:8001/datastore"
os.environ["DATASTORE_HOST"] = "http://localhost:8001"
os.environ["DATASTORE_PROJECT_ID"] = "test"
datastore_client = datastore.Client(
project="test"
)