- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2023 08:33 AM
@Wesley Shen :
it seems like LangChain's SQL Database Agent is designed to work with any SQL database that supports JDBC connections, which includes Databricks SQL. However, it's unclear whether it works with Dolly as Dolly is not mentioned in the documentation.
Assuming that LangChain's SQL Database Agent works with Databricks SQL, you can use the following Python code to create an instance of SQLDatabase from the URI of your Databricks SQL endpoint:
from langchain_sql_database_agent.sql_database import SQLDatabase
# replace <your-databricks-sql-uri> with the URI of your Databricks SQL endpoint
databricks_sql_uri = "<your-databricks-sql-uri>"
db = SQLDatabase.from_uri(databricks_sql_uri)Once you have created an instance of SQLDatabase, you can use it to create an instance of SQLAgentExecutor to execute SQL queries against your Databricks SQL database. Here is an example:
from langchain_sql_database_agent.sql_agent_executor import SQLAgentExecutor
# create an instance of SQLAgentExecutor using the SQLDatabase instance created earlier
agent_executor = SQLAgentExecutor(db)
# execute a SQL query
result = agent_executor.execute_query("SELECT * FROM my_table")
# process the result
for row in result:
print(row)Note that the exact syntax may depend on the version of LangChain's SQL Database Agent you are using, as well as any specific configuration options you need to set for your Databricks SQL endpoint.