Snow CLI

Use Snow CLI to interact with the Snowflake emulator.

Introduction

Snow CLI is a command-line interface (CLI) for Snowflake. You can use Snow CLI to interact with the Snowflake emulator. Snow CLI provides a set of commands to manage and interact with Snowflake accounts, databases, warehouses, and more.

You can connect Snow CLI to the Snowflake emulator using a connection profile. A connection profile is a set of parameters that define the connection to a Snowflake account. You can create, list, and test connection profiles using Snow CLI.

Installation

You can install Snow CLI using the following methods:

pip install snowflake-cli-labs
snow --help
brew tap Snowflake-Labs/snowflake-cli
brew install snowcli
snow --help

Configuring Snow CLI

In this guide, you will learn how to configure Snow CLI to interact with the Snowflake emulator using a localstack connection profile.

Create a connection profile

To configure Snow CLI to interact with the Snowflake emulator, create a connection profile using the following command:

$ snow connection add \
    --connection-name localstack \
    --user test \
    --password test \
    --account test \
    --host snowflake.localhost.localstack.cloud

You might be prompted to enter more optional parameters, such as the connection port, database name, warehouse name, authentication method, and more. These are however optional and can be skipped.

After a successful configuration, you can the localstack connection profile is ready to use.

List your connection profiles

To list all the connection profiles configured in Snow CLI, execute the following command:

$ snow connection list

The output should be:

+-----------------------------------------------------------------------------------+
| connection_name | parameters                                                      |
|-----------------+-----------------------------------------------------------------|
| localstack      | {'account': 'test', 'user': 'test', 'password': '****',         |
|                 | 'host': 'snowflake.localhost.localstack.cloud'}                 |
+-----------------------------------------------------------------------------------+

Test the connection

To test the connection to the Snowflake emulator, execute the following command:

$ snow connection test --connection localstack

The output should be:

+--------------------------------------------------------+
| key             | value                                |
|-----------------+--------------------------------------|
| Connection name | localstack                           |
| Status          | OK                                   |
| Host            | snowflake.localhost.localstack.cloud |
| Account         | test                                 |
| User            | test                                 |
+--------------------------------------------------------+

Run a query using the connection profile

To run a query using the connection profile, execute the following command:

$ snow sql --query "CREATE DATABASE mytestdb;" --connection localstack

You can see all the databases in your Snowflake emulator using the following command:

$ snow sql --query "SHOW DATABASES;" --connection localstack

You can create a schema using the following commands:

$ snow sql --query "CREATE SCHEMA mytestdb.mytestschema;" --connection localstack