Snowflake is a cloud-based data-warehouse. This topic describes how to connect to Snowflake from Domino. To connect successfully, you must have network connectivity between Snowflake and your Domino deployment.
The easiest way to connect to a Snowflake instance from Domino is to use a Domino Data Source.
Retrieve data
After a Snowflake data source is configured, users, who have Domino permissions to use it and have specified their credentials, can use the Domino Data API to retrieve data through the connector.
For more information, see Retrieving data.
Domino recommends the Snowflake Python connector (snowflake-connector-python).
Environment setup
Use the following Dockerfile instruction to install snowflake-connector-python and its dependencies in your environment.
USER root
RUN apt-get install -y libssl-dev libffi-dev && \
pip install -U pip && pip install --upgrade snowflake-connector-python
USER ubuntu
If you encounter an error due to your Ubuntu version, use the following Dockerfile instruction:
USER root
RUN pip install -U pip && pip install --upgrade snowflake-connector-python
USER ubuntu
Credential setup
There are several environment variables you must set up to store secure information about your Snowflake connection. Set the following as Domino environment variables on your user account:
-
SNOWFLAKE_USER
-
SNOWFLAKE_PASSWORD
-
SNOWFLAKE_ACCOUNT
Read Environment variables for secure credential storage to learn more about Domino environment variables.
Usage
Read the Snowflake python connector documentation for detailed information about how to use the package. The following is a simple example.
import snowflake.connector
import os
# Gets the version
ctx = snowflake.connector.connect(
user=os.environ['SNOWFLAKE_USER'],
password=os.environ['SNOWFLAKE_PASSWORD'],
account=os.environ['SNOWFLAKE_ACCOUNT']
cs = ctx.cursor()
try:
cs.execute("SELECT current_version()")
one_row = cs.fetchone()
print(one_row[0])
finally:
cs.close()
ctx.close()
Alternatively, you can use generic Python JDBC or ODBC tools to connect to Snowflake. However, they are not specialized for use with Snowflake. They may have inferior performance and will require more time to set up.
For more information about JDBC / ODBC connections, read: