SnowSQL is a Python based command line interface to connect Snowflake from Windows, Linux, and Mac OS. The SnowSQL is an interactive terminal for Snowflake. You can use it to execute queries, create database objects and perform some of the admin tasks. In this article, we will check how to use Snowsql, what are the SnowSQL command line options.
Snowsql Command Usage
You can use following command to connect to Snowflake using Snowsql.
snowsql -a accountName -u userName -d databaseName -s schemaName
For example, consider following command to connect Snowflake from Windows command line.
C:\Users\viths>snowsql -a xta99637.us-east-1 -u vithaljs -d demo_db -s public
Password:
* SnowSQL * v1.2.1
Type SQL statements or !help
snowuser#COMPUTE_1@DEMO_DB.PUBLIC>
Related Articles,
- Best SQL Editor Available for Snowflake
- Access Snowflake using Snowsql without Password Prompt
- Export Snowflake Table Data to Local CSV format
- How to Execute Snowflake Commands from Shell Script?
snowsql Command Line Options
SnowSQL provide a lot of useful command line options. For example, create tables, execute DML, DDL, load tables, etc. You can call Snowsql from any of your applications that interact with the Snowflake.
Following are the Snowsql command line options.
Option | Option Description |
-a, –accountname TEXT | Name assigned to your Snowflake account. |
-u, –username TEXT | Username to connect to Snowflake. |
-d, –dbname TEXT | Snowflake database. |
-s, –schemaname TEXT | Schema in the database to use. |
-r, –rolename TEXT | Role name to use if any. |
-w, –warehouse TEXT | Warehouse to use if you created specific warehouse. |
-h, –host TEXT | Host address for the connection. |
-p, –port INTEGER | Port number for the Snowflake connection. |
-m, –mfa-passcode TEXT | Token to use for multi-factor authentication (MFA). |
–mfa-passcode-in-password | Appends the MFA passcode to the end of the password. |
–abort-detached-query | Aborts a query execution if the connection between the client and server is lost |
–probe-connection | Test connectivity to Snowflake. |
–authenticator TEXT | Authenticator: ‘snowflake’, ‘externalbrowser’ |
-v, –version | Provides Snowsql current version. |
–noup | Disables auto-upgrade for current run. |
-D, –variable TEXT | Sets a variable to be referred by &<var>. Used in variable substitution. |
-o, –option TEXT | Set SnowSQL options. |
-f, –filename PATH | Execute queries from file. |
-q, –query TEXT | Execute query. |
–config PATH | SnowSQL config file path. |
-P, –prompt | Forces a password prompt. By default, $SNOWSQL_PWD is used |
-M, –mfa-prompt | Forces a prompt for the second token for MFA. |
-c, –connection TEXT | Connection parameters to be used. |
–single-transaction | Auto commit will be disabled. |
–private-key-path PATH | Path to private key file in PEM format used for key pair authentication. |
-U, –upgrade | Upgrade SnowSQL to latest version. |
-K, –client-session-keep-alive | Keeps client session alive indefinitely. |
–disable-request-pooling | Disable request pooling. This can help speed up connection failover |
-?, –help | Show the SnowSQL options and exit. |
Hope this helps 🙂