Managing connections

This topic covers the following subjects:

How to test a connection

You can test your connection configuration by running the snow connection test, similar to the following:

snow connection test --connection="myconnection"

How to use a temporary connection

You can also specify connection parameters from the command line using the --temporary-connection [-x] option. It ignores all definitions from the config.toml, using ones specified by command line options instead. This approach can be helpful for CI/CD use cases when you don’t want to use a configuration file. When you use a temporary connection, Snowflake CLI ignores any connection variables defined in the config.toml file, but does still use any environment variables, such as SNOWFLAKE_ACCOUNT, you set.

snow sql -q "select 42;" --temporary-connection \
                           --account myaccount \
                           --user jdoe
select 42;
| 42 |
| 42 |

You can use the following command options to override connection attributes:

  • --account, --accountname TEXT: Name assigned to your Snowflake account.

  • --user,--username TEXT: Username to connect to Snowflake.

  • --password TEXT: Snowflake password.


    For improved security, Snowflake strongly recommends using the $SNOWFLAKE_PASSWORD environment variable so the password is not included in the logs.

  • --authenticator TEXT: Snowflake authenticator.

  • --private-key-path TEXT: Snowflake private key path.

  • --database,--dbname TEXT: Database to use.

  • --schema,--schemaname TEXT: Database schema to use.

  • --role,--rolename TEXT: Role to use.

  • --warehouse TEXT: Warehouse to use.

  • --temporary-connection [-x]: Use the connection defined with command line parameters instead of one defined in config.toml.

Snowflake CLI uses the following precedence hierarchy to determine which value to use when a parameter is defined in multiple locations:

  • Command-line parameters

  • Connection-specific environment variables, such as SNOWFLAKE_CONNECTION_<name>_USER

  • config.toml file

  • Generic environment variables, such as SNOWFLAKE_USER.

How to use a different configuration file

In some situations, such as a continuous integration, continuous deployment (CI/CD) environment, you might prefer to create dedicated configuration files for testing and deployment pipelines instead of defining all of the possible configurations in a Snowflake default configuration file.

If you want to use a different configuration file instead of your default file, you can use the --config-file option for the snow command, such as:

snow --config-file="my_config.toml" connection test