Google Cloud Datastore Emulator
To develop and test your application locally, you can use theGoogle CloudDatastoreEmulator,which provideslocalemulation of theproduction Google Cloud Datastore environment. You can start the Google CloudDatastore emulator using thegcloud command-line tool.
When you run the Cloud Datastore emulator you will see a message similar to thefollowing printed:
If you are using a library that supports the DATASTORE_EMULATOR_HOSTenvironment variable, run: export DATASTORE_EMULATOR_HOST=localhost:8978Now you can connect to the emulator using theDATASTORE_EMULATOR_HOSTenvironment variable:
require"google/cloud/datastore"# Make Datastore use the emulatorENV["DATASTORE_EMULATOR_HOST"]="localhost:8978"datastore=Google::Cloud::Datastore.newproject:"emulator-project-id"task=datastore.entity"Task","emulatorTask"do|t|t["type"]="Testing"t["done"]=falset["priority"]=5t["description"]="Use Datastore Emulator"enddatastore.savetask
Or by providing theemulator_host argument:
require"google/cloud/datastore"datastore=Google::Cloud::Datastore.newemulator_host:"localhost:8978"task=datastore.entity"Task","emulatorTask"do|t|t["type"]="Testing"t["done"]=falset["priority"]=5t["description"]="Use Datastore Emulator"enddatastore.savetask
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-04 UTC.