jupysql icon indicating copy to clipboard operation
jupysql copied to clipboard

Snowflake Private file support in

Open sivankumar86 opened this issue 2 years ago • 6 comments

Hi Team, We use private key to connect to snowfake however, there is no option at the moment

Workaround, I uses --creator getcon option however, it would be great if it supports out of the box

https://docs.snowflake.com/en/user-guide/python-connector-example.html#using-key-pair-authentication-key-pair-rotation

sivankumar86 avatar Feb 06 '23 01:02 sivankumar86

seems like you need a few functions calls to make this work, so I'm unsure how this could work out of the box. can you provide more detail? how are you calling --creator and how do you think this would work out of the box?

edublancas avatar Feb 06 '23 12:02 edublancas

@edublancas thanks for taking a look

This is my set up now

  1. create a dns.ini file with snowflake setting

  2. Create a function which returns connection def getcon(): ctx = snowflake.connector.connect( user='', account='<account_identifier>', private_key=pkb, warehouse=WAREHOUSE, database=DATABASE, schema=SCHEMA ) return con

  3. create a connection %load-ext sql %sql --select DB_CON_CONFIG1 --creator getcon

  4. You can run snowflake query now

sivankumar86 avatar Feb 06 '23 23:02 sivankumar86

Note: dns.ini file does not support "private_key" parameter as it is using generic URL function instead of snowflake library

from snowflake.sqlalchemy import URL

sivankumar86 avatar Feb 06 '23 23:02 sivankumar86

makes sense. I'm unsure what you mean by out of the box, how would you expect this to work?

edublancas avatar Feb 07 '23 01:02 edublancas

I would like to have a feature to provide a private file in dns.ini file instead of writing custom function. Also, it would be great if we have a GUI extension to enter credential and save at server side instead of creating ini file manually.

Example,

[DB_CONFIG_1] drivername=snowflake host=my.remote.host port=443 database=mydatabase username=myuser private_key =<abs_path>

GUI menu to generate above file instead of manually creating.

form

sivankumar86 avatar Feb 07 '23 02:02 sivankumar86