Connecting To Snowflake
Guide to connecting Genesis API to Genesis Bots Running in Snowflake.
NOTE: Genesis can also be deployed natively on Snowflake as a native application if you are the administrator of your Snowflake account. Refer here for more details.
-
If you are running as a native application, you do not need to use the section below to connect to Snowflake, as you’ll already have a connection.
-
Instead you’ll grant data access to your native application. Refer here for more details.
The below instructions are for connecting to Snowflake if you have installed Genesis using “pip install.”
Connect to Snowflake Using a Username and Password
If you have a username and password for your Snowflake account, you can try connecting with those credentials. If you do not have a password, or can only log in via SSO or MFA (which is increasingly common), instead see the section below called “Configure JWT access to Snowflake.”
You will need to know your account URL and account locator. To get this, in the Snowflake GUI click on your initials in the bottom left corner, select “Account,” select your account, and press the “Copy Account URL” button, and make note of your account locator.
Click the "Copy Account URL" and make note of your account locator
Ask Eve to connect to Snowflake using a username and password
Copy the prompt below to follow along
Reference Example:
Eve will indicate the connection was successful, or any issues she encounters. It’s ok if it takes her a few attempts to make the connection string correctly, she may need to add account or database parameters.
Eve adding a database connection to Snowflake
Now that your connection is made, you can test it.
Copy the prompt below to follow along
Eve running a query on Snowflake
Once you’re connected, see below to add your Snowflake Databases to the Harvest.
NOTE: Some Snowflake accounts do not allow simply connecting with a username and password, the current best practice is to use the private key approach.
You can skip this step if you have connected with a username and password.
Otherwise, follow these steps to set up a private key-based connection.
Configure Keypair Access to Snowflake
Setup Key Pair Authentication
Run the following on your local system to create the private key.
You can update the location of the key based on preference.
Create The Public Key
Run the following to create the public key.
If the private key was encrypted, enter the same passphrase used.
Store The Public Key With The User
In a Snowflake worksheet, alter the user to which the key will be applied to store the public key with the user.
-
Run this on both the accounts listed above (logged in as yourself, using SSO)
-
Replace <username> with your Snowflake username
-
Rsa_public_key is the content of the public key file (rsa_key.pub) generated in the previous step
Testing The Public Key
In order to test that the public key was assigned correctly to the Snowflake user, run the following in Snowflake:
Compare the output from the above statement with output from the command below:
[Optional] Testing Your Connection
Follow the steps in the Test Key Pair Authentication if you would like to test that the Snowflake JWT connection is working properly.
Get Your Account Identifier
In Snowflake’s GUI, hover over your initials in the bottom right corner of the screen, select your account, and copy the account identifier.
Click the "Copy Account Identifier"
It will look like
Next, replace any dots and underscores with dashes and make them lowercase.
Reference Example:
This will be your “account identifier”
Also determine your username, which may be either the result of SELECT CURRENT_USER(), or your email address, if you log in via SSO.
Add a JWT-based Connection to Snowflake to Genesis
Tell Eve you want to connect to Snowflake and provide your account identifier (as determined above), username, and path to your private key file
Reference Example:
Eve adding a connection to Snowflake using private key and external browser authentication
You can then check the Database Connections screen in Genesis GUI to see the new connection.
my_snowflake and other databases connected appear here
Adding Snowflake Databases to the Harvest
You can add any databases you’d like to the harvest.
NOTE: Generally, you’ll want to exclude the INFORMATION_SCHEMA from the harvest unless you’re specifically looking to analyze detailed schema and usage information.
Copy the prompt below to follow along
Eve adding the SPIDER_DATA database to the harvest
After a few minutes, you can see results of the harvest on the Config / Harvester Summary page in the Genesis GUI.
Harvester Status is where you can see all of the data sources being harvested
Chat with Genesis Bots via Genesis API
Once connectivity to the Snowflake account has been established, run the following command to begin chatting with Genesis Bots from the command line.
Format:
Example:
NOTE: Replace username, org-account, role, and private_key_file params as applicable.
Example chat: