Gold ⭐️
Apr 7, 2022 2:17 PM UTC
How to connect to Snowflake in CML
- Oct 5, 2026 8:48 AM UTC
- 0 replies
- 2233 views
- Translate All
This article explains how to connect to Snowflake from Cloudera Machine Learning.
- Save your Snowflake password for your account.
Go to Account Settings > Environment Variables and create a new entry with Name: "SNOW_PASSWORD" and Value: <your password>
-
Create a new session in your CML Project. You can use any of the editors, and a Python kernel:

- Install required Python packages
pip install pandas snowflake-connector-python snowflake-connector-python[pandas] - Initiate the Snowflake connection.
You need to set your Snowflake Account ID and your username for the connection. Your Snowflake password is retrieved from the environment variable that you configured in the Account Settings. I'm using the default Snowflake warehouse and a sample database/schema.import os
import pandas as pd
import snowflake.connector
conn = snowflake.connector.connect(
account='<Account ID>',
user='<Username>',
password=os.environ['SNOW_PASSWORD'],
warehouse='COMPUTE_WH',
database='SNOWFLAKE_SAMPLE_DATA',
schema='TPCH_SF1'
)
query = '''
select * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.CUSTOMER limit 100
'''
pd.read_sql(query, conn) - Once you execute the code, you can see the results:


