.ipynb
.pdf
Databricks
 Contents 
Installation and Setup
Connecting to Databricks
Syntax
Required Parameters
Optional Parameters
Examples
SQL Chain example
SQL Database Agent example
Databricks#
This notebook covers how to connect to the Databricks runtimes and Databricks SQL using the SQLDatabase wrapper of LangChain.
It is broken into 3 parts: installation and setup, connecting to Databricks, and examples.
Installation and Setup#
!pip install databricks-sql-connector
Connecting to Databricks#
You can connect to Databricks runtimes and Databricks SQL using the SQLDatabase.from_databricks() method.
Syntax#
SQLDatabase.from_databricks(
    catalog: str,
    schema: str,
    host: Optional[str] = None,
    api_token: Optional[str] = None,
    warehouse_id: Optional[str] = None,
    cluster_id: Optional[str] = None,
    engine_args: Optional[dict] = None,
    **kwargs: Any)
Required Parameters#
catalog: The catalog name in the Databricks database.
schema: The schema name in the catalog.
Optional Parameters#
There following parameters are optional. When executing the method in a Databricks notebook, you don’t need to provide them in most of the cases.
host: The Databricks workspace hostname, excluding ‘https://’ part. Defaults to ‘DATABRICKS_HOST’ environment variable or current workspace if in a Databricks notebook.
api_token: The Databricks personal access token for accessing the Databricks SQL warehouse or the cluster. Defaults to ‘DATABRICKS_TOKEN’ environment variable or a temporary one is generated if in a Databricks notebook.
warehouse_id: The warehouse ID in the Databricks SQL.
rtdocs_stable/api.python.langchain.com/en/stable/integrations/databricks/databricks.html