Snowsql Command Line Options and Examples

  • Post author:
  • Post last modified:January 22, 2020
  • Post category:Snowflake
  • Reading time:5 mins read

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,

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.

OptionOption Description
-a, –accountname TEXTName assigned to your Snowflake account.
-u, –username TEXTUsername to connect to Snowflake.
-d, –dbname TEXTSnowflake database.
-s, –schemaname TEXTSchema in the database to use.
-r, –rolename TEXTRole name to use if any.
-w, –warehouse TEXTWarehouse to use if you created specific warehouse.
-h, –host TEXTHost address for the connection.
-p, –port INTEGERPort number for the Snowflake connection.
-m, –mfa-passcode TEXTToken to use for multi-factor authentication (MFA).
–mfa-passcode-in-passwordAppends the MFA passcode to the end of the password.
–abort-detached-queryAborts a query execution if the connection between the client and server is lost
–probe-connectionTest connectivity to Snowflake.
–authenticator TEXTAuthenticator: ‘snowflake’, ‘externalbrowser’
-v, –versionProvides Snowsql current version.
–noupDisables auto-upgrade for current run.
-D, –variable TEXTSets a variable to be referred by &<var>. Used in variable substitution.
-o, –option TEXTSet SnowSQL options.
-f, –filename PATHExecute queries from file.
-q, –query TEXTExecute query.
–config PATHSnowSQL config file path.
-P, –promptForces a password prompt. By default, $SNOWSQL_PWD is used
-M, –mfa-promptForces a prompt for the second token for MFA.
-c, –connection TEXTConnection parameters to be used.
–single-transactionAuto commit will be disabled.
–private-key-path PATHPath to private key file in PEM format used for key pair authentication.
-U, –upgradeUpgrade SnowSQL to latest version.
-K, –client-session-keep-aliveKeeps client session alive indefinitely.
–disable-request-poolingDisable request pooling. This can help speed up connection failover
-?, –helpShow the SnowSQL options and exit.

Hope this helps 🙂