Class method to create an SQLDatabase instance from a Databricks connection.
This method requires the 'databricks-sql-connector' package. If not installed,
it can be added using pip install databricks-sql-connector.
from_databricks(
cls,
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 = {}
) -> SQLDatabase| Name | Type | Description |
|---|---|---|
catalog* | str | The catalog name in the Databricks database. |
schema* | str | The schema name in the catalog. |
host | Optional[str] | Default: NoneThe Databricks workspace hostname, excluding 'https://' part. If not provided, it attempts to fetch from the environment variable 'DATABRICKS_HOST'. If still unavailable and if running in a Databricks notebook, it defaults to the current workspace hostname. Defaults to None. |
api_token | Optional[str] | Default: NoneThe Databricks personal access token for accessing the Databricks SQL warehouse or the cluster. If not provided, it attempts to fetch from 'DATABRICKS_TOKEN'. If still unavailable and running in a Databricks notebook, a temporary token for the current user is generated. Defaults to None. |
warehouse_id | Optional[str] | Default: NoneThe warehouse ID in the Databricks SQL. If provided, the method configures the connection to use this warehouse. Cannot be used with 'cluster_id'. Defaults to None. |
cluster_id | Optional[str] | Default: NoneThe cluster ID in the Databricks Runtime. If provided, the method configures the connection to use this cluster. Cannot be used with 'warehouse_id'. If running in a Databricks notebook and both 'warehouse_id' and 'cluster_id' are None, it uses the ID of the cluster the notebook is attached to. Defaults to None. |
engine_args | Optional[dict] | Default: NoneThe arguments to be used when connecting Databricks. Defaults to None. |
**kwargs | Any | Default: {}Additional keyword arguments for the |