How to Install and Connect to Snowflake with SnowSQL CLI

Iman AdekoIman Adeko
3 min read

For the past few weeks, I’ve been learning about Snowflake and how to use its version of SQL, SnowSQL, to perform data management and manipulation tasks. Now, I want to work on a project where I will:

  1. Import and normalize raw data.

  2. Develop a comprehensive data model.

  3. Utilize SnowSQL to execute queries and extract valuable insights.

  4. Create an informative dashboard within Snowflake to effectively communicate my findings."

This article isn't about the project. Instead, it's about how to set up a Snowflake account and install and configure SnowSQL, which is needed to connect to my Snowflake account.

Setting Up Your Snowflake Account

First things first, I got an account on Snowflake. Snowflake is usually a paid service, but you can get a free 30-day trial account with $400 worth of free usage. You only need your name and email address to get one. You can fill any name in the Company name field. I chose the Enterprise Snowflake edition and Google Cloud Platform as my cloud provider (You can choose any of the options). Also, you can choose any region you want. I activated my account via an email sent to me and I set up my username and password.

And voila, i have my Snowflake account set up.

Installing SnowSQL

SnowSQL is a command-line interface (CLI) for connecting to Snowflake and executing SQL queries. Here’s how to install it:

  • Download SnowSQL: Visit the Snowflake website and download the SnowSQL installer for your operating system.

  • Install SnowSQL: Install SnowSQL by running the installer you downloaded earlier and follow the on-screen instructions to complete the installation.

Configuring SnowSQL and Connecting to Snowflake

To connect to Snowflake with SnowSQL, you will need your account name and your username, both of which are in the activation email sent to you by Snowflake.

Above is a screenshot of the activation email i got. The account name is gotten from the dedicated login URL. In my case, my account name is fsxoxgt-so11644 and my username is ADEKOIMAN.

Once you have your account name and username, go to your command prompt and run the code below, replacing account name and username with yours.

snowql -a <accountname> -u <username>

You’ll be prompted to input a password which is the one you used while you were setting up your Snowflake account. Tap on your enter key after inputting your password, and you should be connected to your Snowflake account.

You can now run SnowSQL scripts in your command prompt to perform tasks in your snowflake account.

To avoid entering your account name, username, and password each time you connect to Snowflake, you can save these credentials in SnowSQL’s configuration file. Once you do this, running snowsql in your command prompt will automatically establish a connection to your snowflake account.

You can do this in the following steps:

  • Locate SnowSQL’s config file (The filepath will be similar to this: "C:\Users\USER.snowsql\config").

  • Open the config file with Notepad or any other text editor.

  • Locate the area in the picture above and update accountname, username and password1234 with your own credentials.

  • While this is optional, you can change the connection name from example to any word of your choice. Note that whatever word you use will be used to connect to your snowflake account. I edited mine to [connections.personal].

  • Save the changes.

  • Open a new command prompt window and run the following code (Use your connection name instead)

      snowsql -c personal
    

    You should be automatically connected to your snowflake account.

Conclusion

SnowSQL is essential for working with Snowflake. Many tasks, like importing local files, can only be done using SnowSQL. So, it is import to be familiar with it.

In my next post, I’ll walk you through the project I talked about earlier: modelling and visualizing data in Snowflake.

10
Subscribe to my newsletter

Read articles from Iman Adeko directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Iman Adeko
Iman Adeko