Skip to content

Snowflake CLI

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

You can connect Snowflake 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 Snowflake CLI.

You can install Snowflake CLI using the following methods:

Terminal window
pip install snowflake-cli-labs
snow --help

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

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

Terminal window
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.

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

Terminal window
snow connection list

The output should be:

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

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

Terminal window
snow connection test --connection localstack

The output should be:

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

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

Terminal window
snow sql --query "CREATE DATABASE mytestdb;" --connection localstack

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

Terminal window
snow sql --query "SHOW DATABASES;" --connection localstack

You can create a schema using the following commands:

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