> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to Snowflake

> How to connect Atoti DirectQuery to Snowflake using the Snowflake JDBC driver, including role configuration with `USAGE` and `SELECT` privileges, user setup with default warehouse and namespace, and JDBC connection string with basic or alternative authentication

The Atoti DirectQuery Snowflake connector uses the [Snowflake JDBC driver](https://github.com/snowflakedb/snowflake-jdbc)
to connect to a database.

## User and role

Connecting DirectQuery to Snowflake first requires a user linked to a role with sufficient privileges.
The following actions require a Snowflake 'power user' account.

### How to create a role

The Snowflake [role creation reference](https://docs.snowflake.com/en/sql-reference/sql/create-role.html) describes how to create a role.

### How to grant required privileges to this role

DirectQuery required privileges are:

* `USAGE` privilege on target warehouse
* `USAGE` privilege on target database
* `USAGE` privilege on target schema
* `SELECT` privilege on schema queryable objects (tables, views)

The Snowflake [privilege granting reference](https://docs.snowflake.com/en/sql-reference/sql/grant-privilege.html) describes how to grant these to the new role.

### How to create a user linked to this role

The last step is to create a user with the following attributes:

* login
* password
* default role (the newly created role)
* default warehouse (warehouse which will be used to run the queries)
* default namespace (`YOUR_DATABASE.SCHEMA`)

The Snowflake [user management documentation](https://docs.snowflake.com/en/user-guide/admin-user-management.html#creating-users) covers this step.

## Basic authentication connection

Connection is done through [DirectQuery Snowflake connector](https://docs.activeviam.com/engine/java-sdk/6.2/directquery/getting_started.md#create-the-database-connector) passing the following minimal properties:

* [JDBC connection string](https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string)
* login
* password

## Alternative authentication method

The connection above uses basic authentication.
Snowflake offers other [authentication methods](https://docs.snowflake.com/en/user-guide/authentication.html).
