> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to Databricks

Learn how to connect to a [Databricks Cluster](https://docs.databricks.com/en/clusters/index.html) or [Databricks SQL Warehouse](https://docs.databricks.com/en/sql/admin/create-sql-warehouse.html) from Domino.

## Create a Databricks Data Source

1. From the navigation pane, click **Data > Data Sources**.

2. Click **Create a Data Source**.

3. In the New Data Source window, from **Select Data Store**, select **Databricks**.

4. Enter the server **Host**, **Port**, and cluster/warehouse **HTTP Path**. Details on where to find these can be found on the [Databricks Documentation](https://docs.databricks.com/en/integrations/compute-details.html). The host should not contain the protocol. For example, a valid host format is "name.cloud.databricks.com".

   1. Optional: Enter the initial Catalog and/or Schema to use for this session. If you include schema, you may need to include the corresponding catalog so it can be identifiable.

5. Enter the Data Source **Name** and a **Description** to explain the purpose of the Data Source to others.

6. Enter your **Personal Access Token** to connect to Databricks. The Domino secret store backed by HashiCorp Vault securely stores the credentials.

   <Note>
     If this Personal Access Token expires after you created the Data Source, you can generate a new Personal Access Token on Databricks and edit this field with the new value.
   </Note>

7. Click **Test Credentials** to validate the authentication.

8. Select who can view and use the Data Source in projects.

9. Click **Finish Setup**.

If your users have Domino permissions to use the Data Source and enter their credentials, they can now use the Domino Data API to retrieve data with the connector.

See [Retrieve data](/cloud/platform-capabilities/core-concepts/data/data-source-connectors/use-data-sources) for more information.

## Connect using the Databricks SDK

<Note>
  Domino recommends that you connect to Databricks using Data Sources to take advantage of flexible access controls, the [Domino Data API](/cloud/reference/api/data_api), and receive technical support. However, you can also connect using the [Databricks SDK](https://docs.databricks.com/en/dev-tools/sdk-python.html) if your business requires it. This SDK allows for Databricks workspace and compute management among other data operations.
</Note>

### Prepare your workspace environment

* Ensure you have a workspace environment that uses a Python compatible [workspace IDE](/cloud/platform-capabilities/core-concepts/compute-environments/work-with-pluggable-workspaces/add-workspace-ides) like Jupyter Notebook.

* Add Python 3.8 or above and the Databricks SDK package "databricks-sdk" to the environment. For more information, please see [Add Packages to Environments](/cloud/platform-capabilities/core-concepts/compute-environments/add-packages-to-environments).

<Note>
  You may want to use the [Domino Standard Environment](/cloud/platform-capabilities/core-concepts/compute-environments/manage-compute-environments/2-domino-standard-environments) base image as a starting environment, which is compatible with Python workspace IDEs and contains a Python version above 3.8.
</Note>

### Databricks authentication.

1. Set up a [Databricks configuration profile](https://docs.databricks.com/en/dev-tools/auth.html#config-profiles).

2. Add the ".databrickscfg" file mentioned in the link above to your project.

3. Set the DATABRICKS\_CONFIG\_PROFILE [environment variable](/cloud/platform-capabilities/core-concepts/compute-environments/manage-compute-environments/manage-environment-variables#_define_custom_environment_variables) to be the name of the custom configuration profile you want to use.

4. Launch your workspace.

5. Add the following lines at the top of your code file:

```python theme={null}
from databricks.sdk import WorkspaceClient

w = WorkspaceClient()
```

Alternatively, set environment variables for your workspace using your Databricks workspace host, token, and any other relevant configurations. Pass them in as parameters when calling the WorkspaceClient function:

```python theme={null}
from databricks.sdk import WorkspaceClient

w = WorkspaceClient(
  host  = MY_HOST_VARIABLE,
  token = MY_TOKEN_VARIABLE
)
```

The Databricks SDK is ready to be used in your workspace. For more information, please see the [Databricks SDK documentation](https://databricks-sdk-py.readthedocs.io/en/latest/).

## Next steps

* After connecting to your Data Source, learn how to [Use Data Sources](/cloud/platform-capabilities/core-concepts/data/data-source-connectors/use-data-sources).

* [Share this Data Source](/cloud/platform-capabilities/core-concepts/data/sharing-and-security/share-data-sources) with your collaborators.
