Python: storing data in a Google Cloud data warehouse emulator

I am trying to check local google data store locally. My steps:

  • Scan data with Scrapy
  • Save data to the cloud storage using a local emulator

I followed all the steps to use a local emulator

  • run local emulator: gcloud beta emulators datastore start
  • set local environment variables: gcloud beta emulators datastore env-init

However, in python, when using the following command to access the cloud data store, it always saves the data directly in the Google cloud instead of saving it to local emulators.

 #Imports the Google Cloud client library from google.cloud import datastore # Instantiates a client datastore_client = datastore.Client() sample_entry = some_data # Saves the entity datastore_client.put(sample_entry) 

It looks like you cannot specify the library to use the local data warehouse emulator, as well as what they offer in their Node.js client

 var datastore = gcloud.datastore({ apiEndpoint: "http://localhost:8380" }); 

My question is: how can I ask the python datastore google library to use a local emulator instead of using the cloud directly.

+7
python google-app-engine google-cloud-datastore datastore
source share
1 answer

You need eval $(gcloud beta emulators datastore env-init) .

gcloud beta emulators datastore env-init only prints commands that set the necessary environment variables.

0
source share

All Articles