Get startedGet started for free

VS Code Extension

1. VS Code Extension

So far in this course, we’ve worked exclusively inside the Snowflake browser-based UI, Snowsight. But there are many other ways to experience Snowflake. For example, Snowflake provides a bunch of drivers – like JDBC, node.js, and the Snowflake connector for Python – that you can use to access Snowflake from your preferred development environment and in your preferred language. We’re not going to spend time right now covering how to access Snowflake from a Jupyter notebook, or PyCharm, or a whole host of other IDEs. But I do want to talk about Visual Studio Code, which I’ll call “VS Code” going forward, because there’s a Snowflake extension for VS Code that Snowflake maintains. This Snowflake extension means that working with Snowflake in VS Code is especially straightforward and convenient. And, I’ll be honest, I always feel pretty cool when I’m working in VS Code. Not as hardcore as just living life in a text editor like emacs or VIM and pushing code directly to Github from there, but still… pretty cool. Quick aside: It took me a long time in my tech journey to realize that VS Code, which is also known as Visual Studio Code, is different from Visual Studio – VS Code is a lighter-weight, open-source version that lets you download extensions to get cool functionality that makes it much more than just a text editor. So the first thing we need to do is to download VS Code. We’ll just go to [code.visualstudio.com/download](https://code.visualstudio.com/download) and select the version that fits our machine. For me, that’s the Mac version. What one does after downloading the file depends on whether you’re using a Mac, a PC, or a Linux machine. It’s straightforward either way, but I’ll share the mac approach here. We’ll just go to the downloads folder, then double click on the zip file, and we’ll see the application pop up. We drag it from our downloads folder to our applications folder. Then double click on the Visual Studio Code app to launch it. Okay, great! So now we’re in VS Code. We should see a welcome page. If we go to the lefthand side of the screen, we’ll see five icons. The first one is the explorer, and it lets us look through our folders and files. The second is a search bar that lets us search through open files or folders. The third is a tab that makes it easy to use git in VS Code for version control. The fourth lets us run and debug a file. And the last is the one I want to focus on for a moment – This is where we can search for and install extensions to make our VS Code life easier. We can download autocomplete extensions for different languages. We can download an extension that lets us run a Jupyter notebook inside VS Code. But the one I want to download now is the Snowflake extension. If we search for “Snowflake,” we’ll see that the first result is just called “Snowflake,” and this has a blue check mark signifying that it’s been verified as made by the same owner as Snowflake.com. Awesome. Okay, so we’ll click the blue install button. We now see a “Getting Started” checklist on the Snowflake extension’s Welcome page. So let’s do the first step and add our account. We can find our account name by going to Snowsight, going to the bottom right, hovering over account, hovering over our account’s name, and then clicking on the little “copy account identifier” button. Then we paste that into the VS Code slot for account, but we need to make sure if there’s a period between the first and last portions of the account identifier, that we switch that to a dash. If you already have a dash there, awesome – you can happily move on with your life. After we submit that, we’ll see that we need to enter our username and password. And then we’re ready to get going! So let’s go to “File” at the top of the screen, and select “New File.” Then click on “Snowflake SQL file.” If we go over to the left side of the screen, we can see the database objects we’ve been working with so far in the course. This is a neat benefit of using the Snowflake Extension for VS Code – we get stuff like this out of the box. If we toggle down to Frostbyte_Tasty_Bytes -> analytics -> views -> and hover over menu_v, we can copy that to the clipboard, and paste it in our file. Then we just type SELECT * FROM, and add the semicolon, and run that line using command + enter (on a mac), or ctrl + enter on a PC. Just like in Snowsight, you’ll see the results show down below. We can also see some details about the query in the bottom right. Pretty cool! So what makes the Snowflake extension so cool? Well, for one thing, it has [built-in autocomplete](https://marketplace.visualstudio.com/items?itemName=snowflake.snowflake-vsc). So if we type in SELECT * FROM FROS, we can then autocomplete that, and then we can put a dot and see the schema options, and then we can put a dot and see the tables or views. Autocomplete is great. Another neat thing is that we can hover over keywords and built-in functions, and it will show a link to the documentation for those. We can also see the query history in the bottom left, which is useful. Those are just some of the ways the extension is helpful, but taken together, they make for a pretty sleek developer experience. The last thing I want to mention is that we can change the session context through the VS Code UI. For example, if we hover over a database name in the object explorer, we’ll see a green arrow that says: “Snowflake: Set Execution Context.” If we click that, that database will become the default if we don’t specify a database in a query, say. We can also go up and switch our current role from within the UI. Pretty neat. Look at us. We now know how to install VS Code and the VS Code Snowflake extension, and we can describe the extension UI. We also know how to use the extension to: One, sign in to Snowflake Two, execute Snowflake SQL code Three, examine the SQL query history Four, change the session context And five, navigate the database explorer All that being said, by no means do you need to use VS Code to work with Snowflake. You can use our drivers and connectors to work from wherever you want, or you can work directly from Snowsight, which, I will say, I have become a big fan of. So just know: Among your many options, Snowsight and VS Code with the Snowflake Extension are great ones, and Snowflake actively supports them.

2. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.