sqlalchemy-databricks icon indicating copy to clipboard operation
sqlalchemy-databricks copied to clipboard

[Question] passing http_path as query parameter

Open codebydant opened this issue 3 years ago • 0 comments

Hi @crflynn ,

Thanks for this wonderful tool.

I was wondering if is possible to pass the http_path as a query parameter, e.g:

SQLALCHEMY_DATABASE_URL="databricks+connector://token:<databricks_token>@<databricks_host>:443/<database_or_schema_name>?http_path=<MY_HTTP_PATH>"

This is because I would like to standardize my application so if in the future I want to use another database, I just have to change the URL. The problem that I have at the moment is that I have to define a connect_args in the create_engine function for databricks, but for sqlite o MySQL I don´t need that parameter and raises an error that:

TypeError: 'http_path' is an invalid keyword argument for this function

This is when I run:

engine = create_engine(
        settings.SQLALCHEMY_DATABASE_URL,
        echo=False,
        connect_args={"check_same_thread": False, "http_path": settings.DATABRICKS_HTTP_PATH},
    )

and SQLALCHEMY_DATABASE_URL=sqlite:///./sql_app.db

codebydant avatar Nov 30 '22 11:11 codebydant