Migrating from SnowSQL to Snowflake CLI¶
Caution
Snowflake CLI is the preferred command-line client for new installs and new work. SnowSQL is a legacy command-line client. Snowflake will only add new features and enhancements to Snowflake CLI. Snowflake supports SnowSQL 1.5.x through April 16, 2028. Earlier minor versions have earlier support end dates.
If you’re starting a new project, install Snowflake CLI. If you already use SnowSQL, follow the steps in this topic.
Choose your path¶
- New to Snowflake: Install Snowflake CLI and start with Snowflake in 20 minutes. You don’t need SnowSQL.
- Already using SnowSQL: Follow the migration steps in this topic.
This guide helps you move existing SnowSQL connections, configuration, and SQL workflows to Snowflake CLI.
Migration steps¶
To migrate from SnowSQL to Snowflake CLI, follow these steps:
- Install Snowflake CLI with your preferred method.
- Import your connections.
- Optionally check for suggested changes for your environment variables.
- Optionally create an alias that maps the
snowsqlshell command to thesnow sqlshell command.
Install the Snowflake CLI software¶
For supported platforms and install methods (package installers, Homebrew, and PyPI), see Installing Snowflake CLI. Binaries are also available from the Snowflake CLI binaries repository.
Migrate your SnowSQL connections and settings¶
Snowflake CLI provides a snow helpers command group to simplify the transition from SnowSQL to Snowflake CLI. These helpers are shipped with Snowflake CLI. Use them as follows:
- Run snow helpers import-snowsql-connections once. It copies connection sections into the Snowflake CLI configuration and stops. It doesn’t copy
[variables],[connection_options], or environment variables, and it doesn’t watch SnowSQL afterward. A named connection doesn’t receive keys from the unnamed[connections]section. For the files the command reads, key renaming, the[options]copy, blank values, and the default connection name, see the snow helpers import-snowsql-connections command reference. - Run snow helpers check-snowsql-env-vars to print suggested mappings for SnowSQL environment variables that are set. It doesn’t change the environment. Some suggestions aren’t connection variables that the default Snowflake CLI connection behavior reads. Use the environment-variable table on this page.
To keep existing scripts, map the snowsql command to snow sql.
On Unix-like systems:
In PowerShell:
Scripts keep working when they use these Snowflake CLI forms:
-qor--query, and-for--filename. You can pass-fmore than once.-cor--connection, and-Dor--variable.--accountor--accountname,--useror--username,--databaseor--dbname,--schemaor--schemaname,--roleor--rolename,--warehouse,--host,--port,--protocol, and--private-key-fileor--private-key-path.
These SnowSQL forms aren’t accepted:
-ooptions, includingoutput_format,exit_on_error, andvariable_substitution.--config. The Snowflake CLI flag is--config-file.--warehousename. Use--warehouse.warehousenameis a SnowSQL configuration key.
Roll back to SnowSQL¶
Snowflake CLI uses its own configuration files, so you can continue to use SnowSQL unchanged.
You can install both SnowSQL and Snowflake CLI and run them independently.
If you set the alias in Migrate your SnowSQL connections and settings, remove it to use the snowsql command for SnowSQL.
Migrate your configurations¶
Differences in the configuration files¶
-
SnowSQL
SnowSQL is configured by its configuration file, which is an INI-style file that contains connection configurations, various settings of the tool, and variables that can be used in SQL queries. Configurations can be split across several locations, which lets you define system-wide defaults and override them for different users. You can also specify configurations from custom locations with the
--configcommand-line option. For more information, see Connection parameters reference. -
Snowflake CLI
Snowflake CLI uses TOML configuration files for connections and tool settings. By default, the configuration has no SQL
[variables]section. For variables, use-Dor--variableonsnow sql, or define anenvsection in asnowflake.ymlproject definition file.config.tomllives in the directory described in Location of the `.toml` configuration file. That directory is$SNOWFLAKE_HOMEwhen the variable is set and the directory exists. WhenSNOWFLAKE_HOMEisn’t set, the directory is~/.snowflakeif that directory exists. Otherwise it is a system directory:~/.config/snowflakeon Linux,~/Library/Application Support/snowflakeon macOS, or%USERPROFILE%\AppData\Local\snowflakeon Windows. ASNOWFLAKE_HOMEvalue that points at a missing directory is ignored, and Snowflake CLI doesn’t then use~/.snowflake. Create the directory first. Ifconnections.tomlexists in that directory, connections are read from it and connection entries inconfig.tomlare ignored.default_connection_nameis still read fromconfig.toml.--config-fileselects a specificconfig.toml. It doesn’t moveconnections.toml. Runsnow --infoand readdefault_config_file_pathto see the file this installation uses. For more information, see Location of the `.toml` configuration file and the snow command reference.
Find the Snowflake CLI default configuration file¶
The location of the default Snowflake CLI configuration depends on your system and is determined by the order specified in Location of the `.toml` configuration file.
-
To find the value of the
default_config_file_pathparameter for your Snowflake CLI installation, run thesnow --infocommand as shown:
Import connections from SnowSQL¶
You can import all of your SnowSQL connections with the snow helpers import-snowsql-connections command.
For more information, see Import connections from SnowSQL and the snow helpers import-snowsql-connections command reference.
Manually migrate the default connection configuration¶
If you choose not to import connections using the snow helpers import-snowsql-connections command, you can migrate the default connection manually.
Differences in specifying the default connection include the following:
-
SnowSQL
The default connection is configured in the SnowSQL configuration file, and connection settings are defined directly in the [connections] section.
-
Snowflake CLI
Named connections live under
[connections.<name>]in the Snowflake CLI configuration file. Choose which one is default with the top-leveldefault_connection_namesetting, or runsnow connection set-default(see Set the default connection).
By default both SnowSQL and Snowflake CLI use the default connection configuration to connect to Snowflake. If you have it configured in SnowSQL, migrate it as follows.
If connections.toml exists, add the connection there as a top-level [your_connection_name] section. Connection entries you add under [connections] in config.toml are ignored while connections.toml exists. Set default_connection_name in config.toml either way.
- Open the SnowSQL configuration file and find the default connection parameters in the
[connections]section. You need the values of the connection parameters when adding the connection to Snowflake CLI. - To add the connection to Snowflake CLI, use one of the following methods:
-
Manually edit the configuration, as follows:
-
Open
connections.tomlwhen that file exists. Otherwise openconfig.toml. -
Add the connection. In
connections.toml, use a top-level[your_connection_name]section. Inconfig.toml, use[connections.your_connection_name]. Copy the SnowSQL[connections]values into that section. The import also copieslogin_timeout,client_session_keep_alive,ocsp_fail_open,insecure_mode, andclient_store_temporary_credentialfrom[options]when[connections]omits them. Copying the connection yourself doesn’t include those values, so add them when you want them. -
Change the names of the following parameters, as shown:
accountnametoaccountusernametouserdbnametodatabase.databasenameis a last-resort alias, not a SnowSQL key. Use it only whendatabaseanddbnamearen’t set.schemanametoschemawarehousenametowarehouserolenametorolepwdtopasswordprivate_key_pathtoprivate_key_fileprivate_key_file_pwdtoprivate_key_passphraseproxy_pwdtoproxy_password
When both spellings are present, keep the Snowflake CLI name when it isn’t blank. A blank or whitespace-only value is skipped, so the next name is used. For example,
user=withusername=aliceis saved asuser = "alice". The same rule applies to every pair in those bullets, includingpasswordorpwdandprivate_key_pathorprivate_key_file.private_key_pathwins overprivate_key_filewhen it has a value, and is saved asprivate_key_file. Anaccountvalue isn’t replaced byaccountname. For how the import command resolves a later blank across files, see How keys are renamed. If you copy a private key andauthenticatoris absent, setauthenticator = "SNOWFLAKE_JWT". Ifauthenticatoris present and isn’t JWT, don’t copyprivate_key_fileorprivate_key_passphrase. The comparison ignores case, sosnowflake_jwtkeeps the private key. Write integers and Booleans as described in Values saved on the connection. If the value is left as the string"false", the connector treats it as true. -
Add or set
default_connection_name = "your_connection_name"at the top level ofconfig.toml, including when the connection itself was written toconnections.toml(see Set the default connection).
-
-
Use the
snow connection addandsnow connection set-defaultcommands. For more information, see Manage or add your connections to Snowflake with the `snow connection` commands.
-
Manually migrate your named connection configurations¶
If you don’t use the snow helpers import-snowsql-connections command to import your connections, you can migrate them manually.
Differences in specifying named connections include the following:
-
SnowSQL
Named connections are configured in the SnowSQL configuration file. Each named connection has its own
[connections.your_connection_name]section. -
Snowflake CLI
Snowflake CLI uses almost the same format to configure named connections. You can copy them from the SnowSQL configuration and rename the parameters as specified in the default connection.
Copy each named SnowSQL connection into Snowflake CLI.
If connections.toml exists, add each connection there as a top-level [your_connection_name] section. While connections.toml exists, Snowflake CLI ignores a [connections.your_connection_name] entry in config.toml.
- Open the SnowSQL configuration file and locate the
[connections.your_connection_name]sections. You need the values of the connection parameters when adding the connections to Snowflake CLI. - To add the connection to Snowflake CLI, use one of the following methods:
-
Manually edit the configuration, as follows:
- Open
connections.tomlwhen that file exists. Otherwise openconfig.toml. - Add the connection. In
connections.toml, use a top-level[your_connection_name]section. Inconfig.toml, use[connections.your_connection_name]. Copy the SnowSQL[connections.your_connection_name]values into that section. Copying only[connections.dev]doesn’t include the account that lived on[connections]. The import doesn’t copy those unnamed keys onto a named connection either. Include the account and any other keys that lived only on the unnamed section. The import copieslogin_timeout,client_session_keep_alive,ocsp_fail_open,insecure_mode, andclient_store_temporary_credentialfrom[options]when the connection omits them. Copying the connection yourself doesn’t include those values, so add them when you want them. - Rename the parameters as described in Manually migrate the default connection configuration.
- Open
-
Use the
snow connection addcommand. For more information, see Manage or add your connections to Snowflake with the `snow connection` commands.
-
Configure logs¶
To manually configure logging for Snowflake CLI, see Configure logging.
Migrate your variables¶
Tip
Useful links:
- About project definition files documentation
- Use variables in SQL documentation
- Using variables for SQL templates
The default Snowflake CLI configuration file has no SQL [variables] section. Instead, pass variables on the command line with -D or --variable key=value, or define an env section in a snowflake.yml project definition file.
- Command-line variables such as
-D x=1are referenced as<% x %>. - Project
envvalues are referenced as<% ctx.env.name %>. Thectx.envprefix applies only to project definitionenvvalues, not to-Dvariables. - SnowSQL built-in variables aren’t supported.
The following example defines two project variables: database and role:
Manually migrate your environment variables¶
Tip
Useful links:
- Use environment variables for Snowflake credentials documentation
- Support for system environment variables documentation
In SnowSQL, you can use environment variables (like $SNOWSQL_ACCOUNT and $SNOWSQL_DATABASE) instead of specifying command-line parameters when starting a connection.
The default Snowflake CLI connection behavior doesn’t read SNOWSQL_* variables while connecting, including SNOWSQL_REGION. It also doesn’t read SNOWFLAKE_REGION.
snow helpers check-snowsql-env-vars only prints suggestions and doesn’t change the environment. Treat that output as a checklist. Some suggestions aren’t connection variables that the default Snowflake CLI connection behavior reads. For how the checker treats names, region, and proxy variables, see snow helpers check-snowsql-env-vars. SNOWFLAKE_ENHANCED_EXIT_CODES=1 enables --enhanced-exit-codes for Snowflake CLI commands. That variable isn’t a connection variable, and it isn’t SnowSQL EXIT_ON_ERROR. Use the following table for connection variables the default Snowflake CLI connection behavior reads. See also Use environment variables for Snowflake credentials and Support for system environment variables.
A generic SNOWFLAKE_* variable in the table fills a parameter only when that parameter isn’t already set by a command-line flag or by the selected connection. With --temporary-connection (-x), no saved connection is loaded, so those variables supply the parameters.
To replace one key of a saved connection, set SNOWFLAKE_CONNECTIONS_<NAME>_<KEY>. <NAME> is the connection name in uppercase. <KEY> is the Snowflake CLI key, such as ACCOUNT or PRIVATE_KEY_FILE, rather than the SnowSQL name ACCOUNTNAME. The connection must already exist. This variable replaces that key from the file.
PRIVATE_KEY_PASSPHRASE is separate from the SNOWFLAKE_* variables. For an encrypted private key, it takes precedence over the passphrase stored on the connection.
A passphrase saved from the SnowSQL configuration file is used. PRIVATE_KEY_PASSPHRASE wins when it is set. SNOWSQL_PRIVATE_KEY_PASSPHRASE isn’t read.
SnowSQL stores the private key path in the configuration key private_key_path, not in a SNOWSQL_* environment variable. For that rename, see How keys are renamed.
For the default Snowflake CLI behavior, migrate the following environment variables:
| SnowSQL | Snowflake CLI |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For SNOWSQL_REGION, put the account identifier in SNOWFLAKE_ACCOUNT or on the imported connection’s account. Don’t copy the region name into the account. A region value already in the SnowSQL file is imported as region. The default Snowflake CLI doesn’t read SNOWSQL_REGION or SNOWFLAKE_REGION while connecting.
Connect to Snowflake¶
Assuming that you have migrated your configuration, you can connect to Snowflake from Snowflake CLI using methods similar to those used by SnowSQL, including the following:
- Use the default connection.
- Use a connection with command-line options.
- Use a named configuration.
- Use only command-line options.
- Use environment variables.
- Use a mixture of connections, environment variables, and command-line options.
Use the default connection¶
- To connect using the default configuration defined in your configuration file:
-
SnowSQL
-
Snowflake CLI
-
Use a connection with command-line options¶
- To connect using the default configuration defined in your configuration file and override parameters with command-line options:
-
SnowSQL
-
Snowflake CLI
For a list of possible command-line options, see snow sql. Runtime connection flags override a connection for that command; they don’t save a connection the way
snow connection adddoes. Some options have different names than in SnowSQL (for example,--config-fileinstead of--config). Both clients use--warehouse; Snowflake CLI doesn’t accept--warehousename.
-
Use a named configuration¶
- To connect using a named configuration defined in your configuration file:
-
SnowSQL
-
Snowflake CLI
-
Use only command-line options¶
- To connect using only command-line options instead of a configured connection:
-
SnowSQL
-
Snowflake CLI
Note that Snowflake CLI requires the
--temporary-connection(-x) option for this method.
-
Use environment variables¶
- To connect using the default connection, passing some parameters as environment variables:
-
SnowSQL
-
Snowflake CLI
Note that the names of environment variables differ. For more information, see Use environment variables for Snowflake credentials.
-
Use a mixture of connections, environment variables, and command-line options¶
- To connect using a mixed approach with a named connection, environment variables, and command-line options:
-
SnowSQL
-
Snowflake CLI
You can use this method with both the default and named connections.
-
Run SQL queries¶
You can run PUT and GET with snow sql the same way you run other SQL
statements. For interactive SQL, enter snow sql with no -q or -f option. For details, see
Entering SQL commands in interactive mode.
Run SQL queries from various inputs¶
Snowflake CLI lets you run SQL queries using inputs similar to those handled by SnowSQL. The following examples run SQL queries using various inputs.
-
Run queries using command-line parameters:
-
SnowSQL
-
Snowflake CLI
-
-
Run queries from a file (
-fis repeatable in Snowflake CLI):-
SnowSQL
-
Snowflake CLI
-
-
Run queries from standard input:
-
SnowSQL
-
Snowflake CLI
-
Note
--stdin (-i) is required. cat test.sql | snow sql doesn’t run the file. With no -q, -f, or --stdin, the command reads standard input and then still enters the REPL. That decision is made before the read, so the piped text is discarded. The REPL sees an empty standard input, and the session ends when it reaches the end of that input. The SQL isn’t executed. The snowsql alias in Migrate your SnowSQL connections and settings doesn’t make cat test.sql | snowsql run the file either.
Save query results to a file¶
Snowflake CLI doesn’t support every SnowSQL output formatting option.
Supported --format values are TABLE, JSON, JSON_EXT, and CSV. There is no -o output_file equivalent; use shell redirection.
-
SnowSQL
-
Snowflake CLI
Run queries using variables¶
Both SnowSQL and Snowflake CLI let you use variables in queries. SnowSQL lets you use variables from command-line options, from its configuration file, and using a few built-in variables.
Snowflake CLI doesn’t support variables in its configuration file or SnowSQL built-in variables. It does support -D or --variable on the command line and env values in project definition files. For information about migrating your SnowSQL configuration file variables, see Migrate your variables.
After migrating your variables from SnowSQL’s configuration, you can run Snowflake CLI queries using variables from both command-line options and project definitions.
When using variables, note the following important differences between SnowSQL and Snowflake CLI:
- They use different syntaxes for variable substitutions. SnowSQL uses the
&variableor&{variable}syntax while Snowflake CLI uses<% variable %>. The SnowSQL syntax remains accepted by default, but is deprecated. - Snowflake CLI automatically enables variable substitution, so you don’t need to explicitly enable it as with SnowSQL.
- Project definition
envvalues must be prefixed withctx.env, as shown. Command-line-Dvariables aren’t underctx.env.
The following examples show the differences when running SQL queries with variables:
-
Run a query using variables in command-line options, where
xis the variable name:-
SnowSQL
-
Snowflake CLI
-
Snowflake CLI (using deprecated syntax to facilitate quick migrations)
-
-
Run a query using variables in a SnowSQL configuration versus a Snowflake CLI project definition file:
-
SnowSQL
-
Snowflake CLI
-
Snowflake CLI (using deprecated syntax to facilitate quick migrations)
-
Run queries asynchronously¶
End a statement with ;> instead of ; to schedule it without waiting. This works in the REPL and in noninteractive input (-q, -f, or --stdin). Snowflake CLI prints a scheduled query ID. After the query finishes, retrieve the result with !result <query_id> or RESULT_SCAN.
!queries, !result, and !abort work in the REPL and in snow sql input (-q, -f, and --stdin). !edit fails outside the REPL. The command prints The edit command can only be used in interactive mode.
For details, see Executing SQL queries asynchronously.
SnowSQL and Snowflake CLI feature parity¶
The following table shows how SnowSQL features are integrated into Snowflake CLI.
SnowSQL and Snowflake CLI feature parity
| SnowSQL feature | Snowflake CLI implementation |
|---|---|
Global configuration file (~/.snowsql/config) in an INI-style format. | Configuration uses TOML. For the directory, connections.toml, and --config-file, see Location of the `.toml` configuration file. |
| Connection configuration through command-line options supports everything the Snowflake Connector for Python supports. | Runtime connection flags on commands such as snow sql override the connection for that run; they don’t save a connection. To save a connection, use snow connection add. |
Connection testing via the --probe-connection command-line option. This option is mainly used to print out the TLS/SSL certificate chain. | snow connection test tests whether a session can be created. --enable-diag writes a diagnostic report; --print-diag prints that diagnostic. This isn’t a drop-in TLS chain dump. For more information, see snow connection test. |
Ability to generate and display a JWT token based on the user, account, and private-key-path parameters. | Use the snow connection generate-jwt command. For more information, see snow connection generate-jwt. |
Execute a query from a file using the -f or --filename FILE options. | Use snow sql -f or --filename. The option is repeatable. |
Execute a query from command-line input using the -q or --query TEXT options. | Use snow sql -q or --query; for example, snow sql -q "select emp_id FROM employees". |
Query templating with the option to provide variables using the --variable command-line option, such as --variable db_key=$DB_KEY. | Snowflake CLI supports -D or --variable and snowflake.yml env values (<% ctx.env.name %>). For more information, see Using variables for SQL templates and Storing variables in the `snowflake.yml` project definition file. |
| Interactive SQL shell mode. | Use interactive mode. The REPL and noninteractive snow sql both accept ;> to schedule a query and print its query ID. !queries, !result, and !abort work in the REPL and in noninteractive input. !edit fails outside the REPL. The command prints The edit command can only be used in interactive mode. |
Include, or source, one or more SQL files from another SQL file: | !source and !load are supported. Snowflake CLI fetches https:// URLs. A plaintext http:// URL is rejected before any fetch, and the command prints Plaintext http:// sources are not allowed. An https:// URL that redirects to http:// is rejected too. Local-only mode (--local-only, SNOWFLAKE_CLI_SQL_LOCAL_ONLY, or cli.sql_local_only) blocks https:// URLs, and the command prints Loading SQL from URLs is disabled (--local-only). For more information, see Working with SQL query commands. |
Stop after a SQL error (-o exit_on_error=true). | In noninteractive snow sql, a failed SQL statement stops the command and returns a nonzero exit code. There is no continue-on-error switch. For exit codes, see Enhanced error codes. |