Snowflake CLI のインストール

このトピックでは、 がサポートするすべてのプラットフォーム に Snowflake CLI をインストールする方法を説明します。なお、 Snowflake CLI は現在、 AIX システムでは利用できません。

Snowflakeでは、 Snowflake CLI をシステムにインストールするために、パッケージマネージャなどのバイナリインストール方法を使用することを推奨しています。バイナリー・インストーラーは、公式 Snowflake CLI リポジトリ からダウンロードできます。

要件

  • Snowflake CLI を使用する前に、有効なSnowflakeアカウントが必要です。

  • Snowflake CLI を使用してSnowflake Streamlitを実行するには、Streamlitの使用が許可されたSnowflakeアカウントが必要です。

  • Snowflake CLI を使用してSnowflakeでSnowpark Container Servicesを実行するには、Snowpark Container Servicesを使用する権限を持つSnowflakeアカウントが必要です。

Tip

Snowflakeアカウントに MFA (多要素認証)が必要な場合、 Snowflake CLI にはコマンドごとに承認が必要となります。MFA キャッシュを使うと、4時間に1度だけ認証が必要になります。詳細については、 多要素認証(MFA)を使用する をご参照ください。

パッケージマネージャーを使用して Snowflake CLI をインストールする

パッケージマネージャーを使用して Snowflake CLI をインストールするには、次のプロシージャのいずれかを使用します。

Linuxパッケージマネージャーを使用してインストールする

Linuxオペレーティング・システムを使用している場合、以下をサポートするパッケージ・マネージャーを使ってインストールできます Snowflake CLI:

  • deb パッケージ、

  • rpm パッケージ。

deb パッケージマネージャを使って Snowflake CLI をインストールする:

  1. Snowflake CLI リポジトリ から Snowflake CLI deb をダウンロードします。

  2. 次のコマンドを実行してパッケージをアンインストールします:

    sudo dpkg -i snowflake-cli-<version>.deb
    
    Copy

rpm パッケージマネージャを使って Snowflake CLI をインストールする:

  1. Snowflake CLI repository から Snowflake CLI rpm パッケージをダウンロードします。

  2. 次のコマンドを実行してパッケージをアンインストールします:

    sudo rpm -i snowflake-cli-<version>.deb
    
    Copy
  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  4. Snowflake接続の構成

MacOS パッケージインストーラーでインストールする

MacOS に Snowflake CLI をインストールするには:

  1. Snowflake CLI リポジトリ から Snowflake CLI インストーラをダウンロードします。

  2. インストーラーを実行し、指示に従って Snowflake CLI をインストールします。

  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します:

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  4. Snowflake接続の構成

Windowsインストーラーでインストールする

Windowsに Snowflake CLI をインストールするには、以下を行います:

  1. Snowflake CLI リポジトリ から Snowflake CLI インストーラをダウンロードします。

  2. インストーラーを実行し、指示に従って Snowflake CLI をインストールします。

  3. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します:

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  4. Snowflake接続の構成

Homebrewでインストールする

Mac OSをお使いの場合は、 Homebrew で Snowflake CLI をインストールできます。

  1. 必要であれば、 Homebrew をインストールします。

  2. Homebrewに Snowflake CLI リポジトリへのアクセス権を与えるには、以下のコマンドを実行します:

    brew tap snowflakedb/snowflake-cli
    brew update
    
    Copy
  3. Snowflake CLI をインストールするには、次のコマンドを実行します:

    brew install snowflake-cli
    
    Copy
  4. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  5. Snowflake接続の構成

pipでインストールする (PyPi)

注釈

この方法は、 Snowflake CLI をインストールするPython環境を変更します。依存関係の衝突を避けるため、代わりに pipx を使用することを検討してください。

pip を使用して Snowflake CLI をインストールするには、 Python バージョン3.10以降がインストールされている必要があります。

  1. 次のシェルコマンドを実行します。

    pip install snowflake-cli
    
    Copy
  2. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  3. Snowflake接続の構成

pipxを使用してインストールする

pipx は、Pythonパッケージを分離された仮想環境にインストールして実行する:codenowrap:pip の代替手段を提供します。従って、pip で Snowflake CLI をインストールしても、現在のPython環境は変更されません。

pipx を使用して Snowflake CLI をインストールするには、 pipx がインストールされている必要があります。

  1. 次のシェルコマンドを実行します。

    pipx install snowflake-cli-labs
    
    Copy
  2. ソフトウェアが正常にインストールされたことを確認するには、次のコマンドを実行します。

    snow --help
    
    Copy
    Usage: snow [OPTIONS] COMMAND [ARGS]...
    
    Snowflake CLI tool for developers.
    
    ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ --version                           Shows version of the Snowflake CLI                                                                   │
    │ --info                              Shows information about the Snowflake CLI                                                            │
    │ --config-file                 FILE  Specifies Snowflake CLI configuration file that should be used [default: None]                       │
    │ --install-completion                Install completion for the current shell.                                                            │
    │ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                     │
    │ --help                -h            Show this message and exit.                                                                          │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ app          Manages a Snowflake Native App                                                                                              │
    │ connection   Manages connections to Snowflake.                                                                                           │
    │ cortex       Provides access to Snowflake Cortex.                                                                                        │
    │ git          Manages git repositories in Snowflake.                                                                                      │
    │ notebook     Manages notebooks in Snowflake.                                                                                             │
    │ object       Manages Snowflake objects like warehouses and stages                                                                        │
    │ snowpark     Manages procedures and functions.                                                                                           │
    │ spcs         Manages Snowpark Container Services compute pools, services, image registries, and image repositories.                      │
    │ sql          Executes Snowflake query.                                                                                                   │
    │ stage        Manages stages.                                                                                                             │
    │ streamlit    Manages a Streamlit app in Snowflake.                                                                                       │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    
  3. Snowflake接続の構成

コマンドオートコンプリート機能のインストール

Snowflake CLI は標準的なシェルタブコンプリート機能をサポートしています。

Snowflake CLI にオートコンプリートをインストールするには、次のステップを実行します。

  1. snow --install-completion コマンドを実行します:

    snow --install-completion
    
    Copy
    zsh completion installed in <user home>/.zfunc/_snow
    Completion will take effect once you restart the terminal
    
  2. snow --show-completion コマンドを実行して、シェルプロファイルに追加する必要のあるコマンド(.bashrc.bash_profile.zshrc など)を生成します。

    snow --show-completion
    
    Copy
    _snow_completion() {
       local IFS=$'
    '
       COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                      COMP_CWORD=$COMP_CWORD \
                      _SNOW_COMPLETE=complete_bash $1 ) )
       return 0
    }
    
    complete -o default -F _snow_completion snow
    
  3. コマンド出力テキストを選択してコピーします。

  4. シェルのプロファイルファイル(この例では .bashrc)を開き、コピーしたテキストを貼り付けます。

    export SHELL=/bin/bash
    
    ...
    
    _snow_completion() {
       local IFS=$'
    '
       COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                      COMP_CWORD=$COMP_CWORD \
                      _SNOW_COMPLETE=complete_bash $1 ) )
       return 0
    }
    
    complete -o default -F _snow_completion snow
    
  5. ファイルを保存します。

  6. タブコンプリート機能を有効にするには、シェルを再起動するか、次のようにシェルプロファイルファイルに:codenowrap:source を使用します:

    source ~/.bashrc
    
    Copy
  7. この機能をテストするには、次のようにsnowコマンドの後に TAB を入力します。

    snow app [TAB]
    
    Copy
    deploy    init      open      run       teardown  version