Connecting to Snowflake via python script in Dataiku

Usersyed
Level 3
Connecting to Snowflake via python script in Dataiku

Hi all,

Need help on how to connect to Snowflake via a python script in Dataiku.
I have Snowflake connector already setup but that allows us to get data /tables into the flow.

What I want is to connect to Snowflake via a python script using the snowflake connector.
Tried this 

conn = snowflake.connector.connect(
user='*****',
password='*****',
authenticator="externalbrowser",
account='*****',
role = '***',
warehouse='***',
database='**',
schema='***'
)

I end up getting a URL which I am supposed to copy and paste and then only I will be able to access it.
Is there a better way to do it because in production , nobody would be able to copy paste this redirect URL.

Thanks!


Operating system used: Windows

0 Kudos
4 Replies
HarizoR
Developer Advocate

Hi,

 

You have various options if you want to interact with Snowflake from your Python code:

 

1. Rely on Snowpark Python, see our reference documentation.

2. Rely on Dataiku's SQLExecutor2 which is also compatible with Snowflake connections.

 

In both cases Dataiku takes care of the authentication under the hood so that you don't have to pass credential in plain text in your code.

Hope this helps.

 

Best,

 

 

Harizo

0 Kudos
Usersyed
Level 3
Author

How do we get the value of the connection parameter for the SQLExecutor class function?

0 Kudos
HarizoR
Developer Advocate

Hi,

That would be the name of your Snowflake connection as it appears in Administration > Connections.

 

Best,

 

 

Harizo

0 Kudos
Turribeach

There are other options as well:

  • Use pyodbc and connect via ODBC and Python
  • Use the Snowflake REST API via Python

 

0 Kudos