0

I'm using great_expectations==0.13.4 and sqlalchemy==1.3.22 and am attempting to create the string which will provide the connection in URL format. These will be added manually to the systems, as the CLI does not allow for identification of the CERT or the Schema.

I'm using the following code to define and connect to the URL, while I had this working last night my computer rebooted before I could hit save. I believe the issue is with line "query={"ssl_ca": certificate_file}", but I cannot identify the correct keyword to allow the cert file to be listed in the URL.

Any and all help is appreciated. Thank you

import sqlalchemy
certificate_file = r'c:\Users\Dir\To\My\Certificate.crt'

sqlUrl = sqlalchemy.engine.url.URL(
    drivername='presto',
    username=actual_user,
    password= quote_plus(actual_pswd),
    host= hostname,
    port=port_num,
    database=db_name,
    query={"ssl_ca": certificate_file}
)

engine = sqlalchemy.create_engine(sqlUrl)
with engine.connect() as connection:
    result = connection.execute("show schemas")

The error I get is during the line above ("with engine.connect() as connecton") is

StatementError: (builtins.TypeError) __init__() got an unexpected keyword argument 'ssl_ca'
[SQL: show schemas]

I have tried options in the URL connection for query (request_kwargs, verify & ca, ssl_ca) and some variations there in. So far no luck

Lee_Str
  • 3,266
  • 2
  • 21
  • 32
  • I believe this has been answered here: https://stackoverflow.com/questions/48742736/using-ssl-with-sqlalchemy Looks like the create_engine is where it is defined. – Imjohsep Jan 06 '21 at 01:43
  • I had reviewed that prior to posting this, and several times sense, lol. I need to pass the "create_engine" a URL, not the components themselves. Why you may ask? The python package "Great_Expectations" can connect to presto through SQLAlchemy when submitted a sqlalchemy URL (not connect_engine). Therefore, I'm l need to attach the certificate to the sqlalchemy.engine.url.URL parameters. I can test my create_engine connection is working by passing the URL directly into create_engine, but have to use a URL when using great_expectations. – Lee_Str Jan 08 '21 at 14:17

0 Answers0