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

Connecting to the spanner emulator #6

Closed
jankleinert opened this issue Apr 7, 2021 · 6 comments · Fixed by #8
Closed

Connecting to the spanner emulator #6

jankleinert opened this issue Apr 7, 2021 · 6 comments · Fixed by #8
Assignees

Comments

@jankleinert
Copy link

I'm trying to determine if this can be used with the spanner emulator. I don't see a setting or other way of specifying that it should use the emulator. Is it possible?

@olavloite
Copy link
Collaborator

It is possible, but I think there's room for improvement in how easy it is. The current procedure would be:

  1. Set the environment variable SPANNER_EMULATOR_HOST=localhost:9010.
  2. Start the emulator.
  3. Create an instance and database on the emulator named test-instance and test-database (for example through gcloud CLI).
  4. Start Visual Studio Code and create a new connection in the normal way. Use test-project, test-instance and test-database as values for Project, Instance and Database. Credentials are not needed.
  5. Click Connect.

I've confirmed that the above procedure works. Note that if Visual Studio Code was already running before you set the environment variable, then you will need to restart VS Code.

A possible improvement here would be to add an explicit option to the VS Code connector to automatically configure the connection for the emulator. We did that recently for Java as well, and it was mainly intended for generic tools and frameworks that connect to Spanner through JDBC. That would make connecting to the emulator a lot easier, as it would:

  1. Remove the need to set the environment variable SPANNER_EMULATOR_HOST, which impacts the entire environment of the user (all connections to Spanner will look for this env var).
  2. Remove the need to manually create an instance and database on the emulator.
  3. The need to restart VS Code if it was already running before you set the env var.

@jankleinert
Copy link
Author

Ah, thank you! It was the step to restart VS Code that I was missing.

olavloite added a commit that referenced this issue Apr 16, 2021
- Adds connection options for the Spanner emulator without the need
  to set the environment variable SPANNER_EMULATOR_HOST.
- Automatically creates the instance and database that is referenced
  in the connection if the connection is for the emulator. This
  removes the need to manually create the instance and database on the
  emulator before you can connect and try out simple queries.
- Adds support for DDL statements.

Fixes #6
Fixes #7
olavloite added a commit that referenced this issue Apr 16, 2021
- Adds connection options for the Spanner emulator without the need
  to set the environment variable SPANNER_EMULATOR_HOST.
- Automatically creates the instance and database that is referenced
  in the connection if the connection is for the emulator. This
  removes the need to manually create the instance and database on the
  emulator before you can connect and try out simple queries.
- Adds support for DDL statements.

Fixes #6
Fixes #7
@jankleinert
Copy link
Author

@olavloite Do you know when these changes will be available in the VS Code marketplace? The current version there has a Change Log showing only a single initial release from 3/16

@jankleinert
Copy link
Author

Disregard - I see now that there's a new release, it's just not reflected in the changelog. That would be nice to update, if possible!

@olavloite
Copy link
Collaborator

Disregard - I see now that there's a new release, it's just not reflected in the changelog. That would be nice to update, if possible!

Thanks for noticing that.

I've updated the readme and changelog to reflect the latest changes, but in order to update the Marketplace I need to push a new version. I have one additional feature that I would like to add (make the max 100,000 rows limit configurable), so I'll try to add it tomorrow instead of placing a new version just for updating the changelog.

@olavloite
Copy link
Collaborator

@jankleinert I've made the query limit configurable, updated the changelog and released a new version, so the updated changelog should now be visible in the marketplace for end users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants