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

This version

1.1.1

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.1.1.tar.gz (197.2 kB view details)

Uploaded Source

Built Distribution

snowflake_cli_labs-1.1.1-py3-none-any.whl (104.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for snowflake_cli_labs-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a0249eca633274c1d65fdccdc29bf7732bca6247653b410efbfcc6ee801987bb
MD5 99d7f931ecbfd7ddf115d633a5f4d167
BLAKE2b-256 e040cc3276fccd2246bad7fcb97d59d858c310cea627c8c151e6ecdebe8daee3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snowflake_cli_labs-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ada445077e946c7a5bf8002224ffac308553b5d965290c586e39431fb49ae01
MD5 56c4ca40cdfabb0af042d0d1ce73e7d9
BLAKE2b-256 b9846fc96c3e2a9502f4455c6bcf322717a56da35d697a89b8d363e5d879e213

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