Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add instructions for using a Cloud Spanner emulator #136

Merged
merged 3 commits into from Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/client-usage.rst
Expand Up @@ -50,6 +50,29 @@ Configuration

Be sure to use the **Project ID**, not the **Project Number**.

Using a Cloud Spanner Emulator
------------------------------

There are two ways to use the client with a Cloud Spanner emulator: programmatically or via an environment variable.

To programmatically use an emulator, you must specify the project, the endpoint of the emulator, and use anonymous credentials:

.. code:: python

from google.cloud import spanner
from google.auth.credentials import AnonymousCredentials

client = spanner.Client(
project='my-project',
client_options={"api_endpoint": "0.0.0.0:9010"},
credentials=AnonymousCredentials()
)

To use an emulator via an environment variable, set the `SPANNER_EMULATOR_HOST` environment variable to the emulator endpoint:

.. code::

export SPANNER_EMULATOR_HOST=0.0.0.0:9010

Next Step
---------
Expand Down