2

I am connecting to databricks SQL warehouse for the first time on my local machine (MacOS Venture 13.2.1) via Python 3.11

from databricks import sql
import os

connection = sql.connect(
                        server_hostname = "hostname",
                        http_path = "http path",
                        access_token = "token")

cursor = connection.cursor()

cursor.execute("SELECT * from range(10)")
print(cursor.fetchall())

cursor.close()
connection.close()

and I get the following error in the first connection line:

RequestError: Error during request to server: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

I tried many of the solutions found here with no luck:certificate verify failed: unable to get local issuer certificate

This is a pretty fresh comptuer and Python install, so perhaps I'm missing something?

jarlh
  • 42,561
  • 8
  • 45
  • 63
somethingstrang
  • 1,079
  • 2
  • 14
  • 29

1 Answers1

0

https://github.com/databricks/databricks-sql-python/blob/f99cdd8a8edfcaca890ab9ff0526d40faee6a381/src/databricks/sql/thrift_backend.py#L73

I literally just finished troubleshooting this problem.

So when you do sql.connect you can pass some kwargs, and they'll be passed along to the ThriftBackend, which is where your SSL issue is happening. You could disable it with _tls_no_verify=True, or use _tls_trusted_ca_file="/path/to/cert.pem"

connection = sql.connect(
    server_hostname=server_hostname,
    http_path=http_path,
    access_token=access_token,
    _tls_trusted_ca_file="/path/to/cert.pem"
)
Anthony Roberts
  • 1,971
  • 1
  • 19
  • 34