---
description: Steps to prepare and connect to Snowflake
---

# Connect to Snowflake

## Lightup account setup: Snowflake

### Create a Lightup user on a Snowflake database

{% hint style="info" %}
You must have at least the ACCOUNTADMIN role to set up new accounts.
{% endhint %}

1. Open the SnowSQL Classic Console, then paste the following commands at the prompt.

{% hint style="info" %}
This only grants access to one database. Consider creating a datawarehouse for the databases you want to monitor, and then creating a Lightup login there with the same role.
{% endhint %}

```sql
-- change role to ACCOUNTADMIN
use role ACCOUNTADMIN;
-- create role for lightup
create role if not exists lightup_role;
grant role lightup_role to role SYSADMIN;
-- Note that we are not making the lightup_role; a SYSADMIN,
-- but rather granting users with the SYSADMIN role 
-- power to modify the lightup_role.
-- create a user for lightup
create user if not exists lightup_user password = '<enter password here>';
grant role lightup_role to user lightup_user;
alter user lightup_user set default_role = lightup_role;
-- change role
use role SYSADMIN;
-- grant read only database access 
-- repeat for all database/schemas
grant usage on database <database> to role lightup_role;
grant usage on schema <database>.<schema> to role lightup_role;

-- rerun the following any time a table is added to the schema
grant select on all tables in schema <database>.<schema> to role lightup_role;
-- or
grant select on future tables in schema <database>.<schema> to role lightup_role;
```

2\. Select **All Queries**, and then **RUN**.

<figure><img src="https://3772145110-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7hLPjNTyFMw1VTOP6ZnD%2Fuploads%2FmJOt1aMIjDHtbZlKCXoI%2FSnowSQL-all-queries.png?alt=media&#x26;token=de6748c4-ca48-4216-9468-ac2d86329fc5" alt="Granting roles in the SnowSQL Classic Console "><figcaption></figcaption></figure>

## Connector settings

* **Host Name** - The hostname for the datasource (check the browser address bar; you want the string between **//** and **/**. Example: `https://`**`host.na.me`**`/`
* **Database Name** - The name of the database you're connecting to.
* **Username** - Enter _**lightup\_user**_.
* **Password** - The username account's password.\


#### Query governance

* You can [enable **Query Timeout**](..#open-the-query-governance-settings). Enabling it will cause any query that runs for more than one hour to fail.

### Optional settings

* **Warehouse name** - Specify a Snowflake warehouse for the connection. Read about [Snowflake USE WAREHOUSE](https://docs.snowflake.com/en/sql-reference/sql/use-warehouse.html).&#x20;
* **Role** - Specify a role to use for connecting. Read about [Snowflake USE ROLE](https://docs.snowflake.com/en/sql-reference/sql/use-role.html).
