connection from databricks to snowflake using OKTA

ymt
New Contributor II

Hi team,

This is how I connect to Snowflake from Jupyter Notebook:

import snowflake.connector

snowflake_connection = snowflake.connector.connect(
    authenticator='externalbrowser',
    user='U1',
    account='company1.us-east-1',
    database='db1',
    schema='s1',
    warehouse='WH1'
)

cur = snowflake_connection.cursor()

cur.execute("select col1 from tab1;")

(it redirects me to SSO / OKTA auth page and then works fine)

This is what I get when I try to do the same in my Databricks Notebook:

ImportError: cannot import name 'NamedTuple' from 'typing_extensions' (/databricks/python/lib/python3.9/site-packages/typing_extensions.py)

The error happens on my "snowflake_connection = snowflake.connector.connect" line.

Wait, what?

Ok, this is how I tried to solve it using the very first cell in my Databricks Notebook:

%sh
pip install --upgrade pip
pip install snowflake-connector-python
pip install --upgrade typing_extensions

It worked without error, but didn't actually help.

I've seen other topics regarding Databricks to Snowflake connection here, they suggest to use secrets with Snowflake username / password pair, but I don't have any Snowflake password, I authenticate using SSO / OKTA.

Please advise.