Skip to main content

Snowflake CLI

Project description

Snowflake Developer CLI

Note: Snowflake CLI is in Private Preview (PrPr). You must register for the PrPr to use Snowflake CLI by filling out the Snowflake CLI - PrPr Intake Form. Also, if you want to access Snowflake Container Services through Snowflake CLI, you must register for its PrPr. For more information, you can contact a Snowflake sales representative.

For complete installation and usage instructions, refer to the Snowflake CLI Guide.

Overview

Snowflake CLI is a command line interface for working with Snowflake. It lets you create, manage, update, and view apps running in Snowflake.

This is an open source project and contributions are welcome (though the project is maintained on a best-effort basis).

We plan to incorporate some patterns and features of this CLI into the Snowflake CLI (SnowSQL) in the future. We hope this project starts a conversation about what a delightful developer experience could look like, and we'd love your help in shaping that with us!

Benefits of Snowflake CLI

Snowflake CLI lets you locally run and debug Snowflake apps, and has the following benefits:

  • Search, create, and upload python packages that may not be yet supported in Anaconda.
  • Has support for Snowpark Python user defined functions and stored procedures, warehouses, and Streamlit apps.
  • Define packages using requirements.txt, with dependencies automatically added via integration with Anaconda at deploy time.
  • Use packages in requirements.txt that aren't yet in Anaconda and have them manually included in the application package deployed to Snowflake (only works with packages that don't rely on native libraries).
  • Update existing applications with code and dependencies automatically altered as needed.
  • Deployment artifacts are automatically managed and uploaded to Snowflake stages.

Limitations of Snowflake CLI

Snowflake CLI has the following limitation:

  • To run Streamlit in Snowflake using Snowflake CLI, your Snowflake account must have access to the Streamlit private preview.

Install Snowflake CLI

Install with Homebrew (Mac only)

Requires Homebrew.

brew tap Snowflake-Labs/snowcli
brew install snowcli
snow --help

Install with pip (PyPi)

Requires Python >= 3.8

pip install snowflake-cli-labs
snow --help

Install from source

Requires Python >= 3.8 and git

git clone https://github.com/snowflake-labs/snowcli
cd snowcli
# you can also do the below in an active virtual environment:
# python -m venv .venv
# source .venv/bin/activate
hatch build && pip install .
snow --version

You should now be able to run snow and get the CLI message.

Get started using Snowflake CLI

Use Snowflake CLI to build a function or stored procedure, or create a streamlit if you have access to the Streamlit in Snowflake private preview.

Prerequisites

You must add your credentials to connect to Snowflake before you can use Snowflake CLI. You can add your Snowflake credentials using any of the following methods.

Add credentials with Snowflake CLI

To add Snowflake credentials using the Snowflake CLI connection add command:

  1. Enter the following shell command and supply the connection, account, username, and password when prompted:

    $ snow connection add
    Name for this connection: <connection-name>
    Snowflake account: <account-name>
    Snowflake username: <username>
    Snowflake password: <password>
    

Add credentials using a configuration file

Snowflake CLI lets you add connection definitions to a configuration file. A connection definition refers to a collection of connection parameters.

To add credentials in a configuration file:

  1. In your home directory, create a ~/.snowflake directory:

    $ mkdir ~/.snowflake
    
  2. Create a config.toml file in that directory:

    $ cd ~/.snowflake
    $ touch config.toml
    
  3. In a text editor, open the config.toml file for editing, such as the following for the Linux vi editor:

    $ vi config.toml
    
  4. Add a new Snowflake connection definition. You must prefix the configuration with connections.

    For example, to add a Snowflake connection called myconnection with the credentials: account myaccount, user profile johndoe, and password hunter2, add the following lines to the configuration file:

    [connections]
    [connections.myconnection]
    account = "myaccount"
    user = "jondoe"
    password = "hunter2"
    
  5. If desired, you can add more connections, as shown:

    [connections]
    [connections.myconnection]
    account = "myaccount"
    user = "jondoe"
    password = "hunter2"
    
    [connections.myconnection-test]
    account = "myaccount"
    user = "jondoe-test"
    password = "hunter2"
    
  6. Save changes to the file.

Use environment variables for Snowflake credentials

If you prefer, you can specify Snowflake credentials in system environment variables, instead of specifying them in configuration files. You can use environment variables only to replace connection parameters. Environment variables for the configuration must use the following formats:

  • SNOWFLAKE_<section-name>_<key>=<value>
  • SNOWFLAKE_<section-name>_<option-name>_<key>=<value>

where:

  • <section-name> is the name of the section in the configuration file.
  • <option-name> is the name of the option in the configuration file.
  • <key> is the name of the key

For example: SNOWFLAKE_CONNECTIONS_MYCONNECTION_ACCOUNT="my-account"

You specify some credentials, such as account and user, in the configuration file while specifying the password in an environment variables as follows:

  1. Define the following environment variables, as appropriate for your operating system:

    [connections]
    [connections.myconnection]
    account = "myaccount"
    user = "jdoe"
    
  2. Create a system environment variable for the password using the appropriate naming convention:

    SNOWFLAKE_CONNECTIONS_MYCONNECTION_PASSWORD=pass1234
    

You can also override a value in the configuration file using a system environment variable. Assume the config.toml file contains the following:

[connections]
[connections.myconnection]
account = "myaccount"
user = "jdoe"
password = "xyz2000"

You can supply a different password for that connection by creating the following environment variables:

SNOWFLAKE_CONNECTIONS_MYCONNECTION_PASSWORD=pass1234

In these two examples, Snowflake CLI uses the password "pass1234".

Get involved

Have a feature idea? Running into a bug? Want to contribute? We'd love to hear from you! Please open or review issues, open pull requests, or reach out to us on developers@snowflake.com

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowflake_cli_labs-1.2.0.tar.gz (202.8 kB view details)

Uploaded Source

Built Distribution

snowflake_cli_labs-1.2.0-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

Details for the file snowflake_cli_labs-1.2.0.tar.gz.

File metadata

  • Download URL: snowflake_cli_labs-1.2.0.tar.gz
  • Upload date:
  • Size: 202.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.0

File hashes

Hashes for snowflake_cli_labs-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6000acf107449991b0dafdf5923838edf642110aec906955b02936c7e8d9f50e
MD5 46bfb0676dc130537f7378bf8e0a186e
BLAKE2b-256 3987403367c96d1ae6a56f277ebb6cec6b31e7c156e7b5383c1401ffec45c49a

See more details on using hashes here.

File details

Details for the file snowflake_cli_labs-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snowflake_cli_labs-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8361c8ec5eabd5316ff758a959689ceb1a12a0c9c10f506165d64b85777975b
MD5 c208e5373960df3f24ca693ff5a74617
BLAKE2b-256 a7cc8be48859a2b78290d2aecb0f08a59abe65529464d4294bb6920f14fe1afa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page