> For the complete documentation index, see [llms.txt](https://upsolver.gitbook.io/content/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://upsolver.gitbook.io/content/reference-1/sql-commands/connections/create-connection/snowflake.md).

# Snowflake

To write transformed data into a Snowflake table using Upsolver, you need to create a connection with the appropriate credentials. Upsolver supports two authentication methods for Snowflake:

1. **Username and Password**
2. **Key Pair Authentication**: Requires a username, private key file, and an optional private key passphrase.

## Syntax

{% code overflow="wrap" %}

```sql
CREATE SNOWFLAKE CONNECTION <connection_identifier> 
    CONNECTION_STRING = '<connection_string>' 
    USER_NAME = '<user_name>'
    { PASSWORD = '<password>' 
        | PRIVATE_KEY_FILE='<file_path>' [PRIVATE_KEY_FILE_PWD=<file_passphrase>] }
    [ MAX_CONCURRENT_CONNECTIONS = <integer> ]
    [ COMMENT = '<comment>' ]
```

{% endcode %}

#### Jump to

* [`CONNECTION_STRING`](#connection_string-editable)
* [`USER_NAME`](#user_name-editable-with-password)
* [`PASSWORD`](#password-editable-with-user_name)
* [`PRIVATE_KEY_FILE`](#private_key_file-editable-with-user_name)
* [`PRIVATE_KEY_FILE_PWD`](#private_key_file_pwd-editable-with-private_key_file)
* [`MAX_CONCURRENT_CONNECTIONS`](#max_concurrent_connections-editable)
* [`COMMENT`](#comment-editable)

## Connection options

#### `CONNECTION_STRING` — editable

Type: `text`

The connection string to use when connecting to the database.

Format:&#x20;

```sql
jdbc:snowflake://
    <ACCOUNT_WITH_REGION>.snowflakecomputing.com?
    db=<DB_NAME>&warehouse=<WAREHOUSE_NAME>&role=<ROLE_NAME>
```

Where:

* **`ACCOUNT_WITH_REGION.snowflakecomputing.com`**&#x20;
  * The connection URL in Snowflake.
  * Example: `snowflakedemo.us-east-2.aws.snowflakecomputing.com`
* **`DB_NAME`**&#x20;
  * The name of the database to connect to.
* **`WAREHOUSE_NAME`**&#x20;
  * (Optional) The warehouse name. If not provided, the default warehouse is used. If no default warehouse exists, the `CREATE CONNECTION` command fails.
* **`ROLE_NAME`**
  * (Optional) The name of the role to use when connecting. If not provided, the default role is used. If no default role exists, the `CREATE CONNECTION` command fails. To ensure proper functionality and access for our user when connecting to Snowflake, the following permissions need to be granted in snowflake:&#x20;
    * Grant usage on the specified database:

      <pre class="language-sql"><code class="lang-sql"><strong>GRANT USAGE ON DATABASE &#x3C;database_name> TO ROLE &#x3C;Role_name>;
      </strong></code></pre>
    * Grant usage on the specified schema within the database:

      ```sql
      GRANT USAGE ON SCHEMA <schema_name> TO ROLE <Role_name>;
      ```
    * Grant permissions to create tables and stages within the specified schema:

      ```sql
       CREATE TABLE, CREATE STAGE ON SCHEMA <schema_name> TO ROLE <Role_name>;
      ```
    * Grant permission to create schemas within the specified database:

      ```sql
      CREATE SCHEMA ON DATABASE <database_name> TO ROLE <Role_name>;
      ```

Read more about [connection string arguments in Snowflake](https://docs.snowflake.com/developer-guide/jdbc/jdbc-configure#jdbc-driver-connection-string).

`USER_NAME`&#x20;

Type: `text`

The user to authenticate to the database with.

#### `PASSWORD` — editable with `user_name`

Type: `text`

The password for the user.

#### `PRIVATE_KEY_FILE` - editable with `user_name`&#x20;

Type: `text`

&#x20;Local path to the private key on Upsolver's server.

#### Key-Pair Authentication Setup

**Step 1 - Generate keys**

Configure your Snowflake account for key-pair authentication following the [Snowflake Documentation.](https://docs.snowflake.com/en/user-guide/key-pair-auth#configuring-key-pair-authentication)

**Step 2 - Upload the Key**

Upload the private key to Upsolver's server. Use the resulting file path on the server as the `PRIVATE_KEY_FILE` parameter for the connection setup. For detailed instructions on uploading the key, refer to [this guide](https://docs.upsolver.com/upsolver-1/administration/managing-clusters/uploading-user-provided-certificates).

#### `PRIVATE_KEY_FILE_PWD`- editable with `PRIVATE_KEY_FILE`

(Optional) Specifies the passphrase used to decrypt the private key file if it is encrypted. This parameter must be used alongside `PRIVATE_KEY_FILE`.

`MAX_CONCURRENT_CONNECTIONS` **— editable**

Type: `integer`

(Optional) The maximum number of concurrent connections to the database.&#x20;

Limiting this may reduce the load on the database but could result in longer data latency.

#### `COMMENT` — editable

Type: `text`

(Optional) A description or comment regarding this connection.

## Minimum example

```sql
CREATE SNOWFLAKE CONNECTION my_snowflake_connection
    CONNECTION_STRING = 'jdbc:snowflake://
        snowflakedemo.us-east-1.snowflakecomputing.com?
        db=DEMO_DB&warehouse=DEMO_WH&role=ADMIN'
    USER_NAME = 'your_user'
    PASSWORD = 'your_pass';
```

## Full example

**User-Password Authentication Example**

```sql
CREATE SNOWFLAKE CONNECTION my_snowflake_connection
    CONNECTION_STRING = 'jdbc:snowflake://
        snowflakedemo.us-east-1.snowflakecomputing.com?
        db=DEMO_DB&warehouse=DEMO_WH&role=ADMIN'
    USER_NAME = 'your_user'
    PASSWORD = 'your_pass'
    MAX_CONCURRENT_CONNECTIONS = 23
    COMMENT = 'Snowflake connection example';
```

**Key-Pair Authentication Example**

```sql
CREATE SNOWFLAKE CONNECTION my_snowflake_connection
    CONNECTION_STRING = 'jdbc:snowflake://
        snowflakedemo.us-east-1.snowflakecomputing.com?
        db=DEMO_DB&warehouse=DEMO_WH&role=ADMIN'
    USER_NAME = 'your_user'
    PRIVATE_KEY_FILE = 'path/to/rsa_key_encrypted.p8'
    PRIVATE_KEY_FILE_PWD = 'private_key_passphrase'
    MAX_CONCURRENT_CONNECTIONS = 23
    COMMENT = 'Snowflake connection example';
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://upsolver.gitbook.io/content/reference-1/sql-commands/connections/create-connection/snowflake.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
