🙆

SnowSQLをUbuntu20.04にインストールしてみた

2022/11/29に公開

snowsqlインストール手順

インストーラのダウンロード

ubuntu@dbt:~$ cd /tmp
ubuntu@dbt:/tmp$ sudo curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.7-linux_x86_64.bash

インストーラの実行

ubuntu@dbt:/tmp$ sudo bash snowsql-1.2.7-linux_x86_64.bash
インストーラの途中でディレクトリの場所を聞かれるのでそのままエンター
Specify the directory in which the SnowSQL components will be installed. [~/bin] 
実行ディレクトリをPATHに含めるか聞かれるので、これはyとします。
Do you want to add /root/bin to PATH in /root/.profile? [y/N] y
この通りに進むとインストール成功です
**********************************************************************
 Installing SnowSQL, Snowflake CLI.
**********************************************************************

Specify the directory in which the SnowSQL components will be installed. [~/bin] 
**********************************************************************
 Congratulations! Follow the steps to connect to Snowflake DB.
**********************************************************************

1. Open a new terminal window.
2. Execute the following command to test your connection:
      snowsql -a <account_name> -u <login_name>

      Enter your password when prompted. Enter !quit to quit the connection.

3. Add your connection information to the ~/.snowsql/config file:
      accountname = <account_name>
                username = <login_name>
                password = <password>

4. Execute the following command to connect to Snowflake:

      snowsql

See the Snowflake documentation <https://docs.snowflake.net/manuals/user-guide/snowsql.html> for more information.

snowflakeへ接続してみる

接続コマンド:snowsql -a <account_name> -u <login_name>

ubuntu@dbt:/tmp$ snowsql -a xxxxx.ap-northeast-1.aws -u xxxx
Installing version: 1.2.24  [####################################]  100%             
Password: 
* SnowSQL * v1.2.24
Type SQL statements or !help
xxxx#(no warehouse)@(no database).(no schema)>

コマンド補完してくれます

これはびっくり、なんとコマンド補完してくれます。

show databaseを実行してみる

xxxx#(no warehouse)@(no database).(no schema)>show DATABASES;
+-------------------------------+-----------------------+------------+------------+---------------------------------------+--------------+---------+-----------+----------------+
| created_on                    | name                  | is_default | is_current | origin                                | owner        | comment | options   | retention_time |
|-------------------------------+-----------------------+------------+------------+---------------------------------------+--------------+---------+-----------+----------------|
| 2022-11-22 16:16:23.598 -0800 | AIRBNB                | N          | N          |                                       | ACCOUNTADMIN |         |           | 1              |
| 2022-10-27 17:39:52.768 -0700 | MANAGE_DB             | N          | N          |                                       | ACCOUNTADMIN |         |           | 1              |
| 2022-10-30 18:48:47.546 -0700 | ORDERS                | N          | N          |                                       | ACCOUNTADMIN |         | TRANSIENT | 1              |
| 2022-10-27 17:37:24.022 -0700 | OUR_FIRST_DB          | N          | N          |                                       | ACCOUNTADMIN |         |           | 1              |
| 2022-10-27 16:47:05.808 -0700 | SNOWFLAKE             | N          | N          | SNOWFLAKE.ACCOUNT_USAGE               |              |         |           | 1              |
| 2022-10-30 18:52:07.890 -0700 | SNOWFLAKE_SAMPLE_DATA | N          | N          | SFSALESSHARED.SFC_SAMPLES.SAMPLE_DATA | ACCOUNTADMIN |         |           | 1              |
| 2022-10-28 05:32:58.484 -0700 | STREAMS_DB            | N          | N          |                                       | ACCOUNTADMIN |         | TRANSIENT | 1              |
+-------------------------------+-----------------------+------------+------------+---------------------------------------+--------------+---------+-----------+----------------+
7 Row(s) produced. Time Elapsed: 0.137s

対話モードから抜ける

xxxx#(no warehouse)@(no database).(no schema)>!q
Goodbye!                                                                        
ubuntu@dbt:~$ 

Discussion