databricks-sql-python icon indicating copy to clipboard operation
databricks-sql-python copied to clipboard

SSL Certificate Error Issue before and after Python 3.11.13 with Databricks Instance

Open narquette opened this issue 9 months ago • 3 comments

Overview

When I try to use different versions of python to connect to a databricks environment, I get an SSL certificate issue. It appears to be resolved in 3.11.13 but is broken in versions below (e.g. 3.11.11) and above (3.12, 3.13). Please note that you will need to test with an environment that require an ssl certificate.

Recreation Steps

  1. Setup environment as below
  2. Run script
uv run main.py --python 3.11.11

Expected - The script will output a row count for the specific table Actual - An SSLVerificationError will happen

Hardware Info

  • macOS - 15.5
  • chip - Apple M4 Pro

Affected Python Version

  • 3.11.11, <3.11.13
  • > 3.11.13

Setup

setup uv project

uv init dbks_testing --python

sample uv project template

[project]
name = "dbks-testing"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
    "databricks-sqlalchemy>=2.0.6",
]

script to verify issue

you will need to change the table variable to a valid table for your schema

def main():

    access_token = os.getenv("DATABRICKS_TOKEN")
    server_hostname = os.getenv("DATABRICKS_SERVER_HOSTNAME")
    http_path = os.getenv("DATABRICKS_HTTP_PATH")
    catalog = os.getenv("DATABRICKS_CATALOG")
    schema = os.getenv("DATABRICKS_SCHEMA")

    engine = create_engine(
        url=f"databricks://token:{access_token}@{server_hostname}?" +
            f"http_path={http_path}&catalog={catalog}&schema={schema}"
    )

    session = Session(engine)

    account = Table(table, MetaData(schema=schema), autoload_with=engine)

    print(f"Table count for {account.name} is {session.query(account).count()}")


if __name__ == "__main__":

    # add logging
    logging.getLogger("databricks.sql").setLevel(logging.DEBUG)
    logging.basicConfig(filename="results.log",
                        level=logging.DEBUG,
                        format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")

    # set variables need for main
    table = "account"

    main()

Run command in project

uv run main.py --python 3.11.11

narquette avatar Jun 06 '25 13:06 narquette

Can you try using poetry instead of uv for running all the commands ? Also have you tried manually adding the certificate for Python==3.11.11

jprakash-db avatar Jun 08 '25 10:06 jprakash-db

I’ve tried manually adding the certificate for python and it didn’t work.

I can try poetry as well.

Thanks,

Nick Arquette

On Sun, Jun 8, 2025 at 5:36 AM Jothi Prakash @.***> wrote:

jprakash-db left a comment (databricks/databricks-sql-python#585) https://github.com/databricks/databricks-sql-python/issues/585#issuecomment-2953901317

Can you try using poetry instead of uv for running all the commands ? Also have you tried manually adding the certificate for Python==3.11.11

— Reply to this email directly, view it on GitHub https://github.com/databricks/databricks-sql-python/issues/585#issuecomment-2953901317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFDCFMQGBMOH55TVYJNYJ2L3CQG2TAVCNFSM6AAAAAB6YCZXMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJTHEYDCMZRG4 . You are receiving this because you authored the thread.Message ID: @.***>

narquette avatar Jun 08 '25 11:06 narquette

FWIW I was running into the same issue with 3.11.6 (using poetry), upgrading to 3.11.13 resolved the ssl issue for me.

justinmklam avatar Sep 23 '25 22:09 justinmklam