Snowflake
Snowflake is a data warehouse that offers fast storage, processing, and analytics solutions. Deepnote integrates with Snowflake seamlessly to bring the cloud data warehouse to your notebook.
What can you do with the Snowflake integration?
The Snowflake integration allows you to query databases and explore the structure of your warehouse. Think "SQL editor" but with all the modern productivity boosters that come with Deepnote's notebook. For example:
- Write native SQL and Python in the same notebook
- Search your entire warehouse instantly via the integrated schema explorer
- Get intelligent autocomplete for columns, tables, and databases
- Interactively explore data without writing any additional code
How to connect to Snowflake
Deepnote offers multiple authentication methods for connecting to Snowflake, giving you flexibility based on your security requirements and organizational policies.
Using Snowflake with username and password
This authentication method is straightforward and works well for individual use or when sharing credentials within a team is acceptable for your workflow.
Using Snowflake with key-pair authentication
For enhanced security, Deepnote supports Snowflake's Key-pair authentication, allowing you to authenticate users with private keys instead of passwords.
When creating a Snowflake integration, select "Key-pair" as the authentication type. After creating the integration and connecting it to your project, users will be prompted to provide their username and private key when they first access Snowflake resources through the schema browser or when running queries.
Key-pair authentication provides a more secure alternative to password-based access while maintaining a seamless experience when working with Snowflake data in Deepnote.
Using Snowflake with OAuth
With a Snowflake OAuth authentication, you can give every member of your Deepnote workspace their own set of credentials. You can ensure higher security by using short-lived tokens and enabling the use of multi-factor authentication. Follow the principle of least privilege and use granular access control for various Snowflake resources to ensure everyone can only access the data they need.
Deepnote supports three OAuth providers for Snowflake:
Using Snowflake in Deepnote
Now that you're connected to Snowflake, you can do the following:
-
Click the newly created integration in the Integrations section to open the schema browser. Click here to learn more about the schema browser.
-
Create an SQL block that points to your warehouse and query your data. Autocomplete for columns, tables, and databases will be at your fingertips as you type. Click here to learn more about SQL blocks.
-
Explore column distributions as well as sorting and filtering capabilities on the results set. All results are displayed as an interactive pandas DataFrame. Click here to learn about interactive DataFrame output.
-
Pipe the results of your query into a chart block for rapid interactive data visualization. Click here to learn more about chart blocks.
Allowing Deepnote to access Snowflake
Depending on your Snowflake setup, you might need to explicitly allow Deepnote to connect to your Snowflake instance. This section covers how to check your current configuration and ensure Deepnote can successfully connect.
Checking your current network configuration
By default, new Snowflake accounts allow connections from any IP address. To verify your current setup, you can run:
SHOW PARAMETERS LIKE 'NETWORK_POLICY' IN ACCOUNT;
If this returns no results or a null value, your account has open access and Deepnote should be able to connect without additional configuration.
If your Snowflake account has a network policy that restricts IP addresses, you'll need to add Deepnote's IP addresses to your allow list. This is common in production environments or organizations with strict security requirements.
Adding Deepnote to an existing network policy
If you already have a network policy, you'll need to modify it to include Deepnote's IP addresses:
ALTER NETWORK POLICY your_existing_policy
SET ALLOWED_IP_LIST = ARRAY_APPEND(
ALLOWED_IP_LIST,
'3.220.159.34', '34.236.123.2', '52.5.148.98', '3.230.134.18', '3.209.101.227'
);
Replace your_existing_policy
with the name of your current network policy.
Creating a new network policy for Deepnote
If you don't have a network policy yet but want to create one specifically for controlling access:
CREATE NETWORK POLICY deepnote_access
ALLOWED_IP_LIST = ('3.220.159.34', '34.236.123.2', '52.5.148.98', '3.230.134.18', '3.209.101.227');
Then apply it to your account:
ALTER ACCOUNT SET NETWORK_POLICY = deepnote_access;
Important security considerations
When modifying network policies, remember these important points:
- Include your own IP addresses in the policy to avoid locking yourself out.
- Consider applying the policy to specific users rather than the entire account if you need more granular control:
ALTER USER deepnote_user SET NETWORK_POLICY = deepnote_access;
- Account administrator privileges are required to manage network policies.
- The Deepnote IP addresses listed above may change over time as their infrastructure evolves.
By following these steps, you can ensure that Deepnote has the necessary access to connect to your Snowflake instance while maintaining appropriate security controls.
Connecting to Snowflake via Python
If you prefer to connect to Snowflake with pure Python, you may use the Snowflake connector as shown in the code example below.
import snowflake.connector
conn = snowflake.connector.connect(
user='USER',
password='PASSWORD',
account='ACCOUNT',
warehouse='WAREHOUSE',
database='DATABASE',
schema='SCHEMA'
)
conn.cursor().execute('select * from products')