@@ -38,20 +38,22 @@ def __init__(self, *, schema: str, **kw):
3838
3939 assert '"' not in schema , "Schema name should not contain quotes!"
4040 if (
41- "password" not in kw and " key" in kw
42- ): # if private keys are used instead of password for Snowflake connection, read in key from path specified and pass as "private_key" to connector.
41+ "key" in kw
42+ ): # if private keys are used for Snowflake connection, read in key from path specified and pass as "private_key" to connector.
4343 with open (kw .get ("key" ), "rb" ) as key :
44- p_key = serialization .load_pem_private_key (key .read (), password = None , backend = default_backend ())
44+ p_key = serialization .load_pem_private_key (
45+ key .read (),
46+ password = None if not kw .get ("password" ) else kw .pop ("password" ),
47+ backend = default_backend (),
48+ )
4549
46- pkb = p_key .private_bytes (
50+ kw [ "private_key" ] = p_key .private_bytes (
4751 encoding = serialization .Encoding .DER ,
4852 format = serialization .PrivateFormat .PKCS8 ,
4953 encryption_algorithm = serialization .NoEncryption (),
5054 )
51- self ._conn = snowflake .connector .connect (private_key = pkb , schema = f'"{ schema } "' , ** kw ) # replaces password
5255
53- else : # otherwise use password for connection
54- self ._conn = snowflake .connector .connect (schema = f'"{ schema } "' , ** kw )
56+ self ._conn = snowflake .connector .connect (schema = f'"{ schema } "' , ** kw )
5557
5658 self .default_schema = schema
5759
0 commit comments