Snowflake: VS Code, SQL Tools, and GitHub

David A Spezia
Nov 21, 2020 · 4 min read

VS Code is the preferred IDE for many folks developing code for data and analytics. Now there is an extension allowing you to develop and execute SQL for Snowflake in VS Code. Huge thank you to Peter Kosztolanyi ( in) for creating a Snowflake Driver for the popular SQL Tools IDE extension for VS Code as documented here: https://marketplace.visualstudio.com/items?itemName=koszti.snowflake-driver-for-sqltools.

How to Get the Extension
Open VS Code and navigate to the extensions plugin and search for ‘snowflake.’ Install the free extension by clicking the green ‘Install’ button on the ‘Snowflake Driver for SQL Tools’ extension.

Image for post
Image for post

How to Use the Extension
Now that we have this work of beauty, how do we use it? Click on the database barrel on the left column. Add a connection to your Snowflake account you want to query. Do this by clicking the add connection database barrel with a + sign.

Image for post
Image for post

Click the Snowflake logo; why would you have any other database?

Image for post
Image for post

Enter your account information in the form. Be careful with the account name; you need the account name prefix as specified here: https://docs.snowflake.com/en/user-guide/connecting.html#your-snowflake-account-name. Typically name.re-gion-n.cloud like ‘account.east-us-2.azure’, or the full prefix before the ‘.snowflakecomputing.com’ of your URL.

Image for post
Image for post

This creates a JSON file with the entered settings. Be careful as passwords are stored in plain text here.

Image for post
Image for post

Connect now after testing the connection. Usually, you fat finger warehouse and database names on the first try. Debug this and start querying. The connection has a schema, table, and column browser that is very useful, scrollable, clickable, and context addable.

Image for post
Image for post

You can quickly preview the contents of a table by clicking the + magnifier.

Image for post
Image for post
Image for post
Image for post

The extension comes with IntelliType and many other goodies like collapsing functions and a great IDE. Be careful not to run commands that return millions of results as this can take some time.

Image for post
Image for post

Customizing the Experience
The default run query command highlights the query you want to run and hit Command + E, Command + E…that’s cumbersome. You can also only execute 1 query at a time. You can change the experience to run the highlighted query by hitting Command + Enter like in the Snowflake or Snowsight UI.

Image for post
Image for post

To customize this, open the keyboard shortcuts by simultaneously hitting Command + K and Command + S.

Image for post
Image for post

Search for ‘execute’ and update the ‘SQL Tools Connection: Run Select Query’ command to use Command + Enter. Click on the pencil icon to edit.

Image for post
Image for post

Now hit Command + Enter in the window provided and enter one more time to commit. I recommend doing this for ‘SQL Tools Connection: Run Select Query’ and ‘SQL Tools Connection: Run Highlighted Query’ settings both to Command + Enter.

Image for post
Image for post

Now you can run queries from the cursor with Command + Enter as by default VS Code highlights the code blocks between semicolons.

Image for post
Image for post

Be sure to close your connection, or you will have the heartbeat keep alive function pinging your Snowflake account as set up in the connection.

Integration with GitHub
Several superior blogs and documentation articles are talking about VS Code and GitHub. I add a couple of screenshots here. I have uploaded my code from last week’s article: https://bigdatadave.com/2020/11/15/snowflake-visualizing-tasks-hierarchy-tree-dependencies-in-snowsight/ to GitHub as https://github.com/BigDataDave1/SnowflakeTaskVisualizer.

Image for post
Image for post

Clone a repository, and you can use ‘ https://github.com/BigDataDave1/SnowflakeTaskVisualizer’

Image for post
Image for post

Conclusion
Now you can use one of the most popular and preferred IDEs to develop your SnowSQL Code, integration with Git and the community is just a huge productivity gain. Happy (VS Code SQL Tools for Snowflake) Querying!

Originally published at http://bigdatadave.com on November 21, 2020.

Snowflake

Articles for engineers, by engineers.

David A Spezia

Written by

David spends his time working with Web-Scale Data Applications built on Snowflake with the largest tenants on the Snowflake Data Cloud.

Snowflake

Snowflake

An open forum of tips and best practices from data engineers, data scientists, and experts using Snowflake to power their data.

David A Spezia

Written by

David spends his time working with Web-Scale Data Applications built on Snowflake with the largest tenants on the Snowflake Data Cloud.

Snowflake

Snowflake

An open forum of tips and best practices from data engineers, data scientists, and experts using Snowflake to power their data.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store