Etyr
Contributor II

I had to pip install sqlalchemy-databricks.

from langchain import SQLDatabase
from sqlalchemy.engine import URL
 
TOKEN = "MY-TOKEN"
HOST = "your cloud host .net/.com" # The url for the host
PORT = 443 # your port
DB = "your DB"
CATALOG = "hive_metastore" # The default catalog, can change depending of your configuration
HTTP_PATH = "/sql/1.0/xxxxxxxxxxx"
 
 
URI = URL.create(
    "databricks",
    username="token",
    password=TOKEN,
    host=HOST,
    port=PORT,
    database=DB,
    query={
        "http_path": HTTP_PATH,
        "catalog": CATALOG,
        "schema": DB
    }
)
 
db = SQLDatabase.from_uri(URI)

Help from https://www.andrewvillazon.com/connect-databricks-sqlalchemy/ and https://github.com/hwchase17/langchain/issues/2277