Snowflake

Guide to set up your Snowflake database with Velvet

In this guide, we outline the steps required to securely connect your Snowflake database to your Velvet workspace. You may be able to skip some of these steps if you've previously connected your database to other services.

Depending on whether you're starting a new project from scratch, or connecting a database that's already configured for a third-party tool - this will take between 10 minutes and 2 hours.

  1. Create a read-only user
  2. Set up a static IP address (guide here)
  3. Identify and copy your connection string
  4. Configure which database tables you want to connect with Velvet

1. Create a read-only user

It's best practice to create a user with read-only permissions for products like Velvet. Create a user with read-only permissions in Snowflake.

Create the velvet_read_all_data role and grant the necessary privileges. Create a velvet_readonly user with the password a very good password and assign them the velvet_read_all_data role.

  1. Create a read-only role: velvet_read_all_data.
create role if not exists velvet_read_all_data;
  1. Grant the necessary privileges to the role (code example below).

Grant USAGE on the warehouse to be used for queries.

Grant USAGE on the database and schema with the objects to be accessed.

Grant SELECT on the specific tables or views that can be queried.

GRANT USAGE ON WAREHOUSE your_warehouse_name TO ROLE velvet_read_all_data;
GRANT USAGE ON DATABASE your_database_name TO ROLE velvet_read_all_data;
GRANT USAGE ON SCHEMA your_schema_name TO ROLE velvet_read_all_data;
GRANT SELECT ON ALL TABLES IN SCHEMA your_schema_name TO ROLE velvet_read_all_data;
  1. Create the velvet_readonly user with the password a very good password. Assign the velvet_read_all_data role.
CREATE USER velvet_readonly PASSWORD = 'mypassword';

GRANT ROLE velvet_read_all_data TO USER velvet_readonly;

Snowflake doesn't currently support granting privileges on future tables. You'll need to grant privileges on new tables manually.

Once you've created a read-only user, move on to the next step.

2. Set up a static IP address

Set up a static IP using our static IP configuration guide. Read more about Snowflake's network rules here.

3. Identify and copy your connection string

Find your database connection string to paste it into your Velvet workspace config. If you already have a connection string, jump ahead to section #4.

Or, follow the guide below for building your connection string for the first time.

Build a connection string

Read our general guide on URI construction here. The Snowflake-specific overview is below.

With Snowflake connection strings, you don't need to percent-encode special characters in the parameters. If special characters cause issues or you want to follow best practices, you can still percent-encode them.

Start with the protocol identifier for a Snowflake connection string:

snowflake://

The protocol identifier is followed by the Snowflake account URL which is the address where your Snowflake account is hosted.

The account URL follows the format:

<account-name>.snowflakecomputing.com

The is the unique name assigned to your Snowflake account. It's provided by Snowflake when you sign up for an account.

snowflake://account.snowflakecomputing.com/

Connection parameters come next. The required parameters are user which specifies the login name of the user for the connection and db which specifies the database to use once connected.

snowflake://account.snowflakecomputing.com/?user=peter&db=mydb&schema=public

You can also include additional parameters to customize the connection. These parameters are appended to the connection string and start with a question mark (?).

snowflake://account.snowflakecomputing.com/?user=peter&db=mydb&schema=public

Common parameters::

  • password
  • account
  • warehouse
  • role
  • CLIENT_SESSION_KEEP_ALIVE
  • APPLICATION
  • TIMEZONE
  • QUERYTAG
  • MULTI_STATEMENT_COUNT
  • CLIENT_METADATA_REQUEST_TIMEOUT
  • ROLE
  • DB_CONNECT_OPTIONS

4. Configure your database and tables on Velvet

Configure Snowflake as a remote database connection and select which tables you want connected.

  1. Tap into a workspace in your Velvet dashboard
  2. Tap "Add a data source"
  3. Select type "Remote database"
  4. Name your database
  5. Paste in your database URI. Note: After providing your database credentials for the first time, we manage the connection using ClickHouse. If required, you can add ClickHouse's Static IPs to an allowlist - Read their API documentation here.
  1. Select and configure the table you want to connect as a source.
  1. Name your table and create the source.
  1. Repeat steps 6 and 7 to add each table you want included as a data source.
  2. You can now view, search, and filter data inside your database source.

Great job, you’ve connected your internal database as a data source. We’ll capture data from your connected tables so you can query them in your Velvet workspace.

Email [email protected] for support or feedback.