Setup Visual Studio Code for Snowflake | Learn Snowflake
If you're already in VS Code doing data work, here's how to query Snowflake without ever leaving the editor.
- You need to install the SQL Tools extension first, as it's the engine the Snowflake driver relies on to use VS Code as a database client
- The Snowflake account identifier is your account ID plus region, obtained by stripping everything from .snowflakecomputing.com onwards and from the start of your login URL
- A connection requires a name, account identifier, username, password, database and warehouse, and you can verify it with the Test Connection button before saving
- SQL Tools stores connection settings as JSON, and you should check where this is kept since credentials may be stored as plain text
- The SQL Tools view only loads the first 50 rows, and a session history pane lets you retrieve and re-run any previous queries
0:00Hey, it's Tim here. In today's video, I'm
0:01going to show you how to set up Snowflake
0:03inside of Visual Studio Code.
0:05Now to do that, I'm just going to go ahead
0:06and use Alfred on my Mac to open up VS Code
0:09.
0:10So let's type in Visual Studio Code. It
0:12comes up and here we are in Visual Studio
0:13Code.
0:14Now I've got a completely vanilla setup. So
0:16hopefully if you just got VS Code, you
0:18should be familiar with the landing page
0:20and the getting started page.
0:22The first tool we need to install is called
0:23SQL Tool.
0:24So let's go ahead to the extensions area
0:26here on the left hand side.
0:28Just go to this icon, select it and you'll
0:29see extensions are available.
0:31Now you can search for SQL Tools just by
0:33typing SQL Tools.
0:35And the reason we're looking for this is
0:36because it's actually the main tool that
0:38the Snowflake driver uses.
0:40In essence, the Snowflake plugin uses this
0:42capability to essentially allow you to use
0:45VS Code as a database.
0:47So we're going to go ahead and install SQL
0:48Tools. We'll hit install.
0:50And once that's installed, we can then go
0:52and search for tools that are supported by
0:54this particular extension.
0:56Now, if you want to find out all the
0:57databases that are supported by this, if
1:00you go over here to the left, you'll see we
1:01now have a new cylinder that's been added
1:04to the view.
1:05So let's go ahead and click on that. And
1:06this is where SQL Tools lives.
1:08I'll close this little pane on the right
1:09hand side so we have a completely clear
1:11canvas.
1:12I'll go ahead and add a new connection and
1:14you'll see that we have no connections set
1:16up here.
1:17Now, if you search VS Code Marketplace, it
1:19actually goes and searches all of the
1:21extensions in Visual Studio Code with this
1:23tag here at the top that shows you all the
1:25drivers that are available.
1:27And what you can do is you can just go
1:29ahead and type in Snowflake and you'll find
1:31it straight away.
1:33So this is the only driver for Snowflake
1:35that supports SQL Tools.
1:37So if you go ahead and hit install, that
1:38will work.
1:39Now, let's say you don't know that tag. You
1:40can just type in Snowflake and you'll find
1:42a bunch of tools that allow you to do
1:44various things with Snowflake.
1:46So I'm going to go ahead and install this
1:47one still because that's what I want to use
1:49.
1:50Select SQL Tools, select install.
1:52Now that's installed, when we go back to
1:54our SQL Tools tab, we close this little tab
1:57here and here, we'll see that when we add a
1:59new connection, Snowflake now appears in my
2:02list of database drivers.
2:04We can now go ahead and set up Snowflake.
2:06Let's go ahead and select Snowflake.
2:09And once you've done that, we can give this
2:10connection a name.
2:11So I'll give it a name. I'll call it Snow
2:13flake.
2:15The account that I'm going to use is
2:16actually this always catches me. I never
2:18get this right, whatever service I'm using.
2:20So let me show you how to get this correct
2:21every single time.
2:23What you want to do is you want to copy the
2:24link to your account.
2:26And then once you've got that, this is the
2:28URL that you normally sort of go in and log
2:30into your Snowflake account if you're going
2:32via the browser.
2:33You want to delete everything from .snow
2:36flakecomputing.com and you want to delete
2:39everything from the beginning.
2:41So just remain with these two things.
2:42Essentially your account identifier is the
2:44account and then the Amazon region that it
2:47's hosted in.
2:48So EU West 1 is the one I have and then DC
2:5073084 is my particular account.
2:54Now everything else is going to be pretty
2:55straightforward for this.
2:57So we'll go with my username and we'll go
2:59ahead with my password.
3:02And once we've done that, we're still not
3:03done yet because we need a couple more
3:05things.
3:06Now what I've done is in my notes, I've
3:07gone ahead and copied some of these so I
3:09don't have to type them in front of you.
3:11So let's go ahead and put my Tableau demo
3:13database.
3:14And the warehouse I'm going to use is
3:15called Compute Warehouse.
3:17It's actually an extra small Snowflake Comp
3:19ute instance.
3:21So that's that's all it is.
3:22And once we've typed all those details and
3:23we've made sure we've completed that
3:25correctly, just go down to the very bottom
3:28and you've got the ability to test the
3:30connection over here on the bottom right
3:31hand side.
3:32Let's go ahead and hit that.
3:33If the test is successful, you should see a
3:35green area pop up on the left hand side
3:37right here saying that that was
3:39successfully connected.
3:41So now that that's there, we're ready to
3:42save this connection and we're pretty much
3:45ready to work with Snowflake.
3:47Now you'll see here that you get a JSON
3:49syntax for the connection.
3:51This is essentially how VS Code works.
3:53It's a web tool so it stores everything in
3:54JSON somewhere on the computer.
3:56And this is essentially how it's going to
3:57work.
3:58Now I really hope it doesn't store this as
3:59text.
4:00I'd probably need to do a bit of research
4:01to find that out.
4:03So if you're not 100% certain, go find out
4:05somewhere on the Internet where exactly it
4:07keeps the syntax.
4:09I've blurred it out in my case because I
4:10don't want you to see my username and
4:12password.
4:13But nonetheless, if you go over here to the
4:14left hand side, you can see that the
4:16connection is now available.
4:18So if we go ahead and click on it, you'll
4:19see that it's ready to work.
4:21Now, when I click on it, the first thing it
4:23will do is actually go off and create the
4:25connection and open up a blank SQL canvas.
4:28You can see that that's what it's done here
4:29.
4:30My SQL tool settings is still over here. I
4:32can go ahead and close that.
4:33So every time you do something, it tends to
4:35open a tab here in VS Code.
4:37Now I can run SQL. So what kind of SQL can
4:39I run?
4:40Well, let's go ahead and I'm going to just
4:42go and I'm just going to write something
4:44actually.
4:45Select star from and I'm going to grab, I'm
4:52going to grab some information from a
4:53specific database.
4:55So let's I'm going to grab some text. This
4:57is this is obviously not written for me.
5:02So let's go ahead and hit paste. So
5:04basically what I'm doing is I'm grabbing it
5:05from a specific identifier.
5:07And the identifier is pointing to the
5:09orders table in the public schema in my
5:11Tableau demo database.
5:13And I'm limiting it to 100. I'll come back
5:16to that limit in a second.
5:18Let's go ahead and highlight that. Hit run
5:19on active connection and boom, we get
5:21another tab with our data.
5:23And now we're pretty much good to go. So if
5:25I wanted to, I could just close this tab
5:28with my SQL.
5:29I'll show you how to get that back in a
5:31second. So here we are with my tab with SQL
5:33.
5:34Now the great thing is because this is VS
5:35Code, you can hit command minus or control
5:38minus on a Mac to make it all fit in the
5:40window.
5:41We'll hit command plus to make it larger.
5:42Whatever you want to do, you can do that.
5:44Now, the last thing to show you is here at
5:45the bottom, we have a console.
5:47The console just reads out what's going on.
5:49So you can see here the SQL console
5:50messages successfully executed. 100 rows
5:53were affected.
5:54Now, one of the quirks with this tool is it
5:56only loads the first 50 rows in the view.
5:59If you want more rows, I think there is a
6:00way to sort of page through the rows.
6:03I can't remember how to do that off the top
6:04of my head.
6:05But nonetheless, if you want to export or
6:07work with that data, you're also able to do
6:09that.
6:10We run the query. Everything is all there.
6:12Now, the other thing to bear in mind is all
6:13your SQL queries are actually stored for
6:15that particular session.
6:17So on the left hand side, you can see there
6:18's an actual history that shows you all the
6:20queries you've run.
6:22So if you delete something, you close
6:23something, you want to get it back, you can
6:25obviously go here and find it.
6:26So if I go ahead and tap this, you'll see
6:27it opens up that window. I actually clicked
6:29it twice by mistake.
6:31If I actually go and clear this, you'll see
6:33that as I click on that, it just pastes it
6:35into the SQL window.
6:37Then I'm able to just go ahead and run the
6:38active connection and it just works.
6:41So super simple, nice and easy, a really
6:44good way to use SQL inside of VSCode to do
6:46some work.
6:47If you're already in VSCode to do some
6:48other data work, this is going to be a
6:50handy way of just very quickly doing some
6:53basic work here.
6:54So you don't have to go out to another tool
6:55to do it.
6:56Hopefully you found this video useful. I'm
6:58still learning Snowflake. This is why I've
6:59made this video.
7:00So if you found this video useful and you
7:01're interested in learning Snowflake or
7:03Tableau, this is hopefully a channel to
7:04follow.
7:05So thank you for your time and I'll catch
7:06you in the next video.
7:08[BLANK_AUDIO]
9:59.
10:09[BLANK_AUDIO]
SQL Tools: https://bit.ly/3VbsmHo Snowflake plugin for SQL tools: https://bit.ly/3hVhHCl Visual studio code download: https://bit.ly/3hPYtOG
Release Notes: https://bit.ly/3hPYtOG “A Visual Studio Code extension which extends the SQLTools extension, with a driver to work with the Snowflake Database. It supports tables and views, as well as running queries on Snowflake.”
Timestamps 0:00 Intro 0:22 Installing SQL tools for vs code 0:59 Databases that SQL tools supports 2:06 Using the connection assistant for SQL tools 4:39 Using SQL tools for Snowflake