cancel
Showing results for 
Search instead for 
Did you mean: 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error - Langchain to interact with a SQL database

abd
Contributor

I am using databricks community edition to use langchain on SQL database in databricks.

I am following this link: Interact with SQL database - Databricks

But I am facing issue on this line:

 

db = SQLDatabase.from_databricks(catalog="samples", schema="nyctaxi")

 

 

Error:

 

OperationalError: (databricks.sql.exc.RequestError) Error during request to server: : user not found (Background on this error at: https://sqlalche.me/e/14/e3q8)
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-72a0ed73-c1dd-456a-a142-9b9ed9839d19/lib/python3.11/site-packages/sqlalchemy/engine/base.py:3371, in Engine._wrap_pool_connect(self, fn, connection) 3370 try: -> 3371 return fn() 3372 except dialect.dbapi.Error as e:

File /local_disk0/.ephemeral_nfs/envs/pythonEnv-72a0ed73-c1dd-456a-a142-9b9ed9839d19/lib/python3.11/site-packages/databricks/sql/thrift_backend.py:314, in ThriftBackend._handle_request_error(self, error_info, attempt, elapsed) 309 network_request_error = RequestError( 310 user_friendly_error_message, full_error_info_context, error_info.error 311 ) 312 logger.info(network_request_error.message_with_context()) --> 314 raise network_request_error 316 logger.info( 317 "Retrying request after error in {} seconds: {}".format( 318 error_info.retry_delay, full_error_info_context 319 ) 320 ) 321 time.sleep(error_info.retry_delay)

 

 

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @abd, Looks like you have a permission issue. Make sure the user account has the right permissions and exists in your SQL environment. Double-check that the `catalog` and `schema` names in your code match exactly with those in Databricks. Also, verify your connection settings, including hostname and port, and ensure the JDBC URL is correct. If you're using Dolly, confirm its compatibility or try testing with Databricks SQL directly. If issues persist, you might try using LangChain’s SQL tools directly instead of the toolkit. 

Sources:
- [LangChain + Databricks SQL + Dolly]
- [LangChain SQLDatabase Agent Errors]

KumaranT
New Contributor III

Hi @abd,

Can you check upgrading the SQL driver?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group