Get startedGet started for free

Snowflake CLI

1. Snowflake CLI

There are a few moments where I feel more like a developer than when I open up my terminal and start doing stuff. You might think less of me because of this confession, but I even feel cool when I'm just changing directories and listing files. A little `cd` here, a little `ls` there — very powerful, very normal. With that said, I'm excited that we're about to set up Snowflake's command-line interface, which I'll call the Snowflake CLI from here on out. Let's do it. The first thing we need to do is install the CLI. If you've seen an older version of this course, you may have seen an install command that referenced something like `snowflake-cli-labs`. That package has been deprecated. The correct install command today is simply `pip install snowflake-cli`, which can be typed into your terminal environment. Once that's done, we can confirm the install worked by checking the version with `snow --version`. The CLI tool is called `snow`, and that's what we'll be typing at the start of every command. Now, before we do anything useful with it, we need to set up a connection so the CLI knows how to reach our Snowflake account. This is the step that trips most people up the first time, so let's go through it carefully. The CLI stores connection information in a configuration file. We can find out where that file is by running `snow connection list`. If you haven't set anything up yet, this will return an empty list. Since you're likely setting this up for the first time, yours should be blank. Let's add a connection using `snow connection add`. The CLI walks you through a series of prompts. You'll give the connection a name — let's call ours `dev` — and then fill in your account identifier, username, and either a password or the path to a private key if you're using key-pair authentication. You can also specify a default role, warehouse, database, and schema, which is useful because you won't have to set those up every time you run a command. Once that's saved, let's run `snow connection list` again to confirm it's there. Now, let's test the connection to make sure it actually works using `snow connection test --connection dev`. Great — we're connected. Now, let's take a look at what the Snowflake CLI can actually do by taking a peek into the built-in help manual. We can access this by typing `snow --help`. You can see a bunch of command groups here. Let me quickly walk through the ones most relevant to this course. `snow object` lets you list, describe, and drop Snowflake objects right from the terminal. If you want to see your warehouses without opening Snowsight, you can just run this command. `snow sql -q` lets you run a SQL query directly from the terminal. The `-q` is the flag for running a query. This is handy for quick checks or for scripting. `snow notebook` is a newer addition that lets you manage Snowflake Notebooks from the terminal. You can execute a notebook on-demand, which is particularly useful for scheduling or triggering notebook runs from a pipeline without going through the Snowsight UI. Then there is `snow cortex`, which we'll use extensively in the next module when we get into Snowflake's AI capabilities. I won't go deep on it here since you haven't seen Cortex yet, but I want you to know it exists so the CLI feels like a complete picture. The short version is that `snow cortex` lets you call Cortex AI functions directly from the terminal, which is very useful for scripting and for automation. We'll come back to it soon. One last thing worth knowing is `snow git`, which lets you sync a Snowflake project with a Git repository. If you're version-controlling your Snowflake objects, `snow git` is how you push and pull those changes without leaving the terminal. Let me also quickly mention the config file directly, because sometimes you'll want to edit it by hand rather than using the interactive prompts. It lives at `~/.snowflake/config.toml` on Mac and Linux. You can open it in any text editor and you'll see a straightforward TOML format with your connection name as a section header and your credentials as key-value pairs underneath. If you're managing multiple environments — such as `dev`, `staging`, and `production` — you just add multiple named sections and switch between them with the `--connection` flag on any command. To recap, in this video we covered five things: 1. The correct install command is `pip install snowflake-cli`, not the older `snowflake-cli-labs` version. 2. We set up a named connection using `snow connection add` and tested it with `snow connection test`. 3. `snow object` and `snow sql` give you quick terminal access to your Snowflake objects and queries. 4. `snow notebook` lets you execute notebooks from the terminal, useful for pipelines and scheduling. 5. `snow cortex` and `snow git` are coming up — Cortex in the next module, and Git when you're ready to version-control your Snowflake projects. The more you use the Snowflake CLI, the more you'll find yourself reaching for it instead of the UI for routine tasks. It's fast, it's scriptable, and as we'll see in Module 3, it connects directly to some of Snowflake's most powerful features.

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.