port undefined error in SQLDatabase.from_databricks (langchain.sql_database)

Octavian1
Contributor

The following assignment:

from langchain.sql_database import SQLDatabase

dbase = SQLDatabase.from_databricks(
catalog=catalog,
schema=db,
host=host,
api_token=token,
)

fails with 

ValueError: invalid literal for int() with base 10: ''
because of
cls._assert_port(port),
in /lib/python3.10/site-packages/sqlalchemy/engine/url.py:211, in URL.create(cls, drivername, username, password, host, port, database, query)
as shown in the error trace.
 
Couldn't find any information regarding this (for instance, in the example given in: https://docs.gcp.databricks.com/en/large-language-models/langchain.html)
 
The token and host are OK. Also the catalog and schema have correct values.
 
Using langchain==0.1.5.

 

Hi @Retired_mod 

You may be right regarding SQLAlchemy, the trace hints at something related:

> /lib/python3.10/site-packages/langchain_community/utilities/sql_database.py", line 133, in from_uri

> """Construct a SQLAlchemy engine from URI."""

But I don't get why in the SQLDatabase.from_databricks documentation there is no mention of any port parameter, neither in the example notebooks?

Thanks,

Octavian

vburam
New Contributor II

I am also facing the same issue. not able to connect even after using sqlalchemy

vburam
New Contributor II

SQL alchemy url: databricks+https://<token>@abc.cloud.databricks.com:443/sql/1.0/warehouses/9265c8e0?catalog=customer&schema=chatbot