<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sneha Shah on Medium]]></title>
        <description><![CDATA[Stories by Sneha Shah on Medium]]></description>
        <link>https://medium.com/@snehashah16?source=rss-c25fcf9ae321------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*pSobRXQ6C4H8OwMTByEY4w.png</url>
            <title>Stories by Sneha Shah on Medium</title>
            <link>https://medium.com/@snehashah16?source=rss-c25fcf9ae321------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:15:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@snehashah16/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cloud Spanner Emulator]]></title>
            <link>https://medium.com/google-cloud/cloud-spanner-emulator-bf12d141c12?source=rss-c25fcf9ae321------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf12d141c12</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Sneha Shah]]></dc:creator>
            <pubDate>Thu, 09 Apr 2020 08:44:32 GMT</pubDate>
            <atom:updated>2021-02-16T19:04:58.175Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*YJxqJzSWCkPCrb5q3MLUJQ.png" /></figure><p>After Cloud Spanner’s launch in 2017, there has been a huge customer adoption across several different industries and verticals. With this growth, we have built a large community of application developers using Cloud Spanner. To make the service even more accessible and open to the broader developer community, we are introducing an offline emulator for the Cloud Spanner service. The Cloud Spanner emulator is intended to reduce application development cost and improve developer productivity for the customers.</p><p>The Cloud Spanner emulator provides application developers with the full set of APIs, including the breadth of SQL and DDL features that could be run locally for prototyping, development and testing. This open source emulator will provide application developers with the transparency and agility to customize the tool for their application use.</p><p>This blog introduces the Cloud Spanner emulator and will guide you through installation and use of the emulator with the existing Cloud Spanner CLI and client libraries.</p><h3>What is Cloud Spanner Emulator ?</h3><p>The Cloud Spanner emulator provides a local, in-memory, high-fidelity emulator of the Cloud Spanner service. You can use the emulator to prototype, develop and hermetically test your application locally and in your integration test environments.</p><p>Because the emulator stores data in-memory, it will not persist data across runs. The emulator is intended to help you use Cloud Spanner for local development and testing, not for production deployments. However, once your application is working with the emulator, you can proceed to end-to-end testing of your application by simply changing the Cloud Spanner endpoint configuration.</p><h3>Supported Features</h3><p>The Cloud Spanner emulator exposes the complete set of Cloud Spanner APIs including instances, databases, SQL, DML, DDL, sessions, and transaction semantics. Support for querying schema metadata for a database is available via <a href="https://cloud.google.com/spanner/docs/information-schema">Information Schema</a>. Both <a href="https://cloud.google.com/spanner/docs/reference/rpc">gRPC</a> and <a href="https://cloud.google.com/spanner/docs/reference/rest">REST</a> APIs are supported and can be used with the existing <a href="https://cloud.google.com/spanner/docs/reference/libraries">client libraries</a>, <a href="https://cloud.google.com/spanner/docs/use-oss-jdbc">OSS JDBC driver</a> as well as the <a href="https://cloud.google.com/sdk/gcloud/reference/spanner">Cloud SDK</a>. The emulator is supported natively on Linux, and requires <a href="https://www.docker.com/products/docker-desktop">Docker</a> on MacOS and Windows platforms. To ease the development and testing of an application, IDEs like IntelliJ and Eclipse can be configured to directly communicate with the Cloud Spanner emulator endpoint.</p><p>The emulator is not built for production scale and performance, and therefore should not be used for load testing or production traffic. Application developers can use the emulator for iterative development, and to implement and run unit and integration tests.</p><p>A detailed list of features and limitations is provided on Cloud Spanner emulator <a href="https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/blob/master/README.md#technical-details">README</a>. The emulator is currently (as of April 2020) in beta release and will be continuously enhanced for feature and API parity with Cloud Spanner service.</p><h3>Using the Cloud Spanner Emulator</h3><p>This section describes using the existing Cloud Spanner CLI and client libraries to interact with the emulator.</p><h3>Before You Start</h3><ul><li>Install <a href="https://cloud.google.com/sdk/docs/">Cloud SDK</a></li><li>Configure <a href="https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login">gcloud credentials</a></li><li>Install <a href="https://www.docker.com/products/docker-desktop">Docker</a>, if using MacOS or Windows</li></ul><h3>Starting the emulator locally</h3><p>The emulator can be started using Docker or using the Cloud SDK CLI on Linux, MacOS and Windows. In either case, MacOS and Windows would require an <a href="https://www.docker.com/products/docker-desktop">installation of docker</a>.</p><h3>Docker</h3><pre>$ docker pull gcr.io/cloud-spanner-emulator/emulator<br>$ docker run -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator</pre><p>Note: The first port is the gRPC port and the second port is the REST port.</p><h3>Cloud SDK CLI</h3><pre>$ gcloud components update<br>$ gcloud emulators spanner start</pre><p>Other alternatives to start the emulator, including pre-built linux binaries, are listed <a href="https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/blob/master/README.md#quickstart">here</a>.</p><h3>Setup Cloud Spanner Project &amp; Instance</h3><p>Configure Cloud Spanner endpoint, project and disable authentication:</p><pre>$ gcloud config configurations create emulator<br>$ gcloud config set auth/disable_credentials true<br>$ gcloud config set project test-project<br>$ gcloud config set api_endpoint_overrides/spanner <a href="http://localhost:9020/">http://localhost:9020/</a></pre><pre><br># Verify gCloud is working with the Cloud Spanner Emulator.<br>$ gcloud spanner instance-configs list</pre><pre>NAME            DISPLAY_NAME<br>emulator-config Emulator Instance Config</pre><pre><br># Create a Cloud Spanner Instance<br>$ gcloud spanner instances create test-instance --config=emulator-config --description=”Test Instance” --nodes=1</pre><p><em>Note</em>:</p><pre># To switch back to the default config:<br>$ gcloud config configurations activate default</pre><pre># To switch back to the emulator config:<br>$ gcloud config configurations activate emulator</pre><h3>Using Cloud Spanner Client Libraries</h3><p>With the beta lunch, the latest versions of Java, Go and C++ Cloud Spanner client libraries are supported to interact with the emulator. Use the <a href="https://cloud.google.com/spanner/docs/tutorials">Getting Started</a> guides to try the emulator.</p><p>This is an example of running the Java client library with the emulator:</p><p><strong><em>Prerequisite</em></strong>: Setup Cloud Spanner Project and Instance from step above.</p><pre># Configure emulator endpoint<br>$ export SPANNER_EMULATOR_HOST=”localhost:9010&quot;</pre><pre># Cloning java sample of client library.<br>$ git clone <a href="https://github.com/GoogleCloudPlatform/java-docs-samples">https://github.com/GoogleCloudPlatform/java-docs-samples</a> &amp;&amp; cd java-docs-samples/spanner/cloud-client<br>$ mvn package</pre><pre># Create database<br>$ java -jar target/spanner-google-cloud-samples-jar-with-dependencies.jar createdatabase test-instance example-db</pre><pre># Write into database<br>$ java -jar target/spanner-google-cloud-samples-jar-with-dependencies.jar write test-instance example-db</pre><pre># Query from database<br>$ java -jar target/spanner-google-cloud-samples-jar-with-dependencies.jar query test-instance example-db</pre><p>Follow the rest of the sample for Java client library using the <a href="https://cloud.google.com/spanner/docs/getting-started/java#create_a_database">Getting Started Guide</a>.</p><h3>Using the Cloud SDK CLI</h3><p><strong><em>Prerequisite</em></strong>: Setup Cloud Spanner Project and Instance from step above.</p><pre># Configure emulator endpoint<br>$ gcloud config configurations activate emulator</pre><pre># Create a database<br>$ gcloud spanner databases create test-database --instance test-instance --ddl “CREATE TABLE TestTable (Key INT64, Value STRING(MAX)) PRIMARY KEY (Key)”</pre><pre># Write into database<br>$ gcloud spanner rows insert --table=TestTable --database=test-database --instance=test-instance --data=Key=1,Value=TestValue1</pre><pre># Read from database<br>$ gcloud spanner databases execute-sql test-database --instance test-instance --sql “select * from TestTable”</pre><h3>Using the open source command-line tool spanner-cli</h3><p>Follow examples for an interactive prompt to Cloud Spanner database with <a href="https://github.com/cloudspannerecosystem/spanner-cli#example">spanner-cli</a>.</p><p><strong><em>Prerequisite</em></strong>: Setup Cloud Spanner Project, Instance and Database from step above.</p><pre># Configure emulator endpoint<br>$ export SPANNER_EMULATOR_HOST=”localhost:9010&quot;</pre><pre># Start the spanner-cli<br>$ go get github.com/cloudspannerecosystem/spanner-cli<br>$ go run github.com/cloudspannerecosystem/spanner-cli -p test-project -i test-instance -d test-database</pre><pre>spanner&gt; INSERT INTO TestTable (Key, Value) VALUES (2, “TestValue2”), (3, “TestValue3”);<br>Query OK, 2 rows affected</pre><pre>spanner&gt; SELECT * FROM TestTable ORDER BY Key ASC;<br>+ — — -+ — — — — — — — — +<br>| Key  | Value           |<br>+ — — -+ — — — — — — — — +<br>| 2    | TestValue2      |<br>| 3    | TestValue3      |<br>+ — — -+ — — — — — — — — +<br>2 rows in set</pre><pre>spanner&gt; exit;</pre><h3>Conclusion</h3><p>Cloud Spanner emulator reduces application development cost and improves developer productivity for Cloud Spanner customers. We plan to continue building and supporting customer requested features and you can follow <a href="https://github.com/GoogleCloudPlatform/cloud-spanner-emulator">Cloud Spanner emulator</a> on GitHub for more updates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf12d141c12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/cloud-spanner-emulator-bf12d141c12">Cloud Spanner Emulator</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>