<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Connect langchain with databricks unity catalog in Databricks Free Edition Help</title>
    <link>https://community.databricks.com/t5/databricks-free-edition-help/connect-langchain-with-databricks-unity-catalog/m-p/127464#M434</link>
    <description>&lt;P&gt;Team,&lt;/P&gt;&lt;P&gt;Please help me connect langchain with databricks unity catalog&lt;/P&gt;</description>
    <pubDate>Tue, 05 Aug 2025 13:50:36 GMT</pubDate>
    <dc:creator>Aimlwithakash</dc:creator>
    <dc:date>2025-08-05T13:50:36Z</dc:date>
    <item>
      <title>Connect langchain with databricks unity catalog</title>
      <link>https://community.databricks.com/t5/databricks-free-edition-help/connect-langchain-with-databricks-unity-catalog/m-p/127464#M434</link>
      <description>&lt;P&gt;Team,&lt;/P&gt;&lt;P&gt;Please help me connect langchain with databricks unity catalog&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 13:50:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/databricks-free-edition-help/connect-langchain-with-databricks-unity-catalog/m-p/127464#M434</guid>
      <dc:creator>Aimlwithakash</dc:creator>
      <dc:date>2025-08-05T13:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Connect langchain with databricks unity catalog</title>
      <link>https://community.databricks.com/t5/databricks-free-edition-help/connect-langchain-with-databricks-unity-catalog/m-p/127490#M435</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Steps Explained: Connect LangChain with Databricks Unity Catalog&lt;/STRONG&gt;&lt;/H3&gt;&lt;H4&gt;1. &lt;STRONG&gt;Install Required Packages&lt;/STRONG&gt;&lt;/H4&gt;&lt;LI-CODE lang="markup"&gt;pip install langchain databricks-sql-connector&lt;/LI-CODE&gt;&lt;H4&gt;2. &lt;STRONG&gt;Configure Access to Databricks Unity Catalog&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;Use &lt;STRONG&gt;Databricks SQL Connector&lt;/STRONG&gt; to connect to Unity Catalog tables.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from databricks import sql

conn = sql.connect(
    server_hostname = "&amp;lt;your-databricks-workspace-url&amp;gt;",  # e.g. "adb-1234567890123456.7.azuredatabricks.net"
    http_path       = "&amp;lt;sql-endpoint-http-path&amp;gt;",         # From Databricks SQL Warehouse
    access_token    = "&amp;lt;your-personal-access-token&amp;gt;"      # Or use Databricks secrets
)

cursor = conn.cursor()
cursor.execute("SELECT * FROM catalog_name.schema_name.table_name LIMIT 5")
result = cursor.fetchall()

for row in result:
    print(row)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;NOTE PS:This works for tables registered in &lt;/SPAN&gt;&lt;STRONG&gt;Unity Catalog&lt;/STRONG&gt;&lt;SPAN&gt; — ensure the SQL Warehouse you're using has access to the correct catalog/schema/table.&lt;/SPAN&gt;&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;3.Use with LangChain: SQLDatabaseChain&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;Now you can use LangChain's SQLDatabaseChain to query your Delta tables.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from langchain.chains import SQLDatabaseChain
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.sql_database import SQLDatabase
from langchain.chat_models import ChatOpenAI

db = SQLDatabase.from_databricks(
    catalog="your_catalog",
    schema="your_schema",
    token="&amp;lt;your-access-token&amp;gt;",
    host="adb-xxx.azuredatabricks.net",
    http_path="&amp;lt;your-http-path&amp;gt;"
)

llm = ChatOpenAI(temperature=0)

db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True)

# Ask a question
db_chain.run("What is the average usage in the last 7 days?")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 16:53:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/databricks-free-edition-help/connect-langchain-with-databricks-unity-catalog/m-p/127490#M435</guid>
      <dc:creator>CURIOUS_DE</dc:creator>
      <dc:date>2025-08-05T16:53:08Z</dc:date>
    </item>
  </channel>
</rss>

