Configuring a client, driver, library, or third-party application to connect to Snowflake¶
To configure a client, driver, library, or third-party application to connect to Snowflake, you must specify your Snowflake account identifier. In addition, you might need to specify the warehouse, database, schema, and role that should be used.
You can find this information in Snowsight or by executing SQL commands:
Using Snowsight to get connection settings¶
To get the settings that you can use to configure a client, driver, library, or third-party application:
Sign in to Snowsight.
Open the user menu by selecting your user name.
From the user menu, select Connect a tool to Snowflake to display the Account Details dialog.
Tip
You can also display the account details from the account selector.
Select one of the following tabs:
If your client, driver, library, or third-party application supports using a TOML configuration file (for example, Snowflake CLI, Snowflake Python APIs, or the Snowflake Connector for Python:
Select the Config file tab.
To specify a warehouse in the configuration file, select the warehouse from the Warehouse menu.
To specify a database and schema in the configuration file, use the Database menu to select the database and schema.
From the Connection Method menu, select the method that you plan to use to authenticate:
To use browser-based single sign-on (SSO), select Web Browser.
To use a password, select Password.
Note
Clients, drivers, libraries, and third-party applications support additional authentication methods not listed in the menu. For information, see Securing Snowflake.
Select the copy icon (
) to copy the content for the configuration file.
Note
For the Snowflake Python APIs, underscores are not supported in the
account
setting. If the account identifer includes underscores, replace them with dashes.If your client, driver, library, or third-party application supports specifying a connection string (for example, the ODBC Driver, JDBC Driver, Go Snowflake Driver, or .NET Driver):
Select the Connectors/Drivers tab.
From the Select Connector or Driver menu, select the driver that you want to use.
To specify a warehouse in the connection string, select the warehouse from the Warehouse menu. (Note that this menu is not present for ODBC and .NET.)
To specify a database and schema in the connection string, use the Database menu to select the database and schema.
From the Connection Method menu, select the method that you plan to use to authenticate:
To use browser-based single sign-on (SSO), select Web Browser.
To use a password, select Password.
Note
Clients, drivers, libraries, and third-party applications support additional authentication methods not listed in the menu. For information, see Securing Snowflake.
Select the copy icon (
) to copy the resulting connection string.
To execute SQL commands to get the configuration information:
Using SQL commands to get connection settings¶
You can execute SQL commands to get the following information needed to configure your client, driver, library, or application:
Setting |
SQL command |
---|---|
Account identifier for the current account |
|
Current user name |
SELECT CURRENT_USER();
|
Current role |
SELECT CURRENT_ROLE();
|
Current region |
SELECT CURRENT_REGION();
|
Current warehouse |
SELECT CURRENT_WAREHOUSE();
|
Current database |
SELECT CURRENT_DATABASE();
|
Current schema |
SELECT CURRENT_SCHEMA();
|
Account formats used by clients and drivers¶
For different clients and drivers, you use different syntaxes for specifying your account.
In general, you should use the variation that includes the organization name (orgname
) and account name
(account_name
).
One exception to this rule is when you’re using the Client Redirect feature. If you’re
using this feature, replace the name of the account (account_name
) with the name of the connection
(connection_name
). For examples of this syntax, see Using a connection URL.
To configure a private connection to the Snowflake service, add .privatelink
to either the account name or the account
locator syntax. To determine which value you should use to connect to Snowflake when using private connectivity, call the
SYSTEM$GET_PRIVATELINK_CONFIG function in your Snowflake account.
If you need to use the account locator, you might also need to specify the cloud region ID, the cloud, and the level of government
compliance as additional segments after the account locator. For the format to use, see Format 2: Account locator in a region. In the
examples below, account_locator_with_additional_segments
represents the account location with any additional segments
that are required.
- SnowSQL:
Account name:
snowsql -a orgname-account_name
Account locator:
snowsql -a account_locator_with_additional_segments
For additional information, see Connection syntax.
- JDBC:
Account name:
jdbc:snowflake://orgname>-<account_name.snowflakecomputing.com/?connection_paramsr
Account locator:
jdbc:snowflake://account_locator_with_additional_segments.snowflakecomputing.com/?connection_params
For additional information, see JDBC Driver connection string.
- ODBC:
Account name:
Server:
orgname-account_name.snowflakecomputing.com
Account locator:
Server:
account_locator_with_additional_segments.snowflakecomputing.com}
For additional information, see ODBC configuration and connection parameters.
- Python:
Account name:
Set the
ACCOUNT
parameter value asorgname-account_name
.
Account locator:
Set the
ACCOUNT
parameter value asaccount_locator_with_additional_segments
.
For additional information, see Connecting to Snowflake with the Python Connector.
- .Net:
Account name:
Set the
ACCOUNT
parameter value asorgname-account_name
.Set the
HOST
parameter value as the default (.snowflakecomputing.com
).
Account locator:
Set the
ACCOUNT
parameter value asaccount_locator_with_additional_segments
.Set the
HOST
parameter value as the default.snowflakecomputing.com
. Specify if your Snowflake account is not in theus-west
region.
For additional information, see Connecting.
- Golang:
Account name:
db, err := sql.Open("snowflake", "jsmith:mypassword@orgname-account_name/mydb/testschema?warehouse=mywh")
Account locator:
sql.Open("snowflake", "jsmith:mypassword@account_locator_with_additional_segments/mydb/testschema?warehouse=mywh")
For additional information, see Connection String.
- node.js:
Account name: Set the
ACCOUNT
parameter value asorgname-account_name
.Account locator: Set the
ACCOUNT
parameter value asaccount_locator_with_additional_segments
.
For additional information, see Managing connections.
- Spark (connector):
Account name: Same as JDBC
Account locator: Same as JDBC
For additional information, see Setting Configuration Options for the Connector.
- Spark (Databricks):
Account name:
Account URL for Snowflake account
Account locator:
Account Locator URL for Snowflake account
For additional information, see Configuring Snowflake for Spark in Databricks.
- Spark (Qubole):
Account name: Set the Host Address field value as
orgname-account_name.snowflakecomputing.com
.Account locator: Set the Host Address field value as
account_locator_with_additional_segments.snowflakecomputing.com
.
For additional information, see Configuring Snowflake for Spark in Qubole.
- PHP:
Account name:
Set the
ACCOUNT
parameter value asorgname-account_name
.Leave the
REGION
parameter value blank for all regions.
Account locator:
Set the
ACCOUNT
parameter value asaccount_locator
.Set the
REGION
parameter value if your Snowflake account is not in theus-west
region.
For additional information, see Connecting to the Snowflake database.
- SQLAchemy:
Account name:
snowflake://user_login_name:password@orgname-account_name
Account locator:
snowflake://user_login_name:password@account_locator_with_additional_segments
For additional information, see Using the Snowflake SQLAlchemy toolkit with the Python Connector.
Additional configuration steps¶
The next topics cover specific areas of configuring a connection: