Databricks
  • 25 Apr 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Databricks

  • Dark
    Light
  • PDF

Overview

In this article we will discuss how to connect a Databricks database to Preset using two methods:

So let's get started!


Allowlist Preset IPs

Preset Cloud currently runs on three regions with the IPs listed below, and those need to be allowlisted so Preset can access your data.

Before starting, please take a moment to allowlist the IPs below based on the region that you're deployed in.

us-west-2 us-east-1 eu-north-1 ap-northeast-1
35.161.45.11 44.193.153.196 13.48.95.3 35.74.159.67
54.244.23.85 52.70.123.52 13.51.212.165 35.75.171.157
52.32.136.34 54.83.88.93 16.170.49.24 52.193.196.211

Retrieve Databricks Information

Step 1: Get Databricks Token

In Databricks, navigate to User SettingsAccess TokensGenerate New Token.

Databricks_Get_Token

Step 2: Get Host and URL

Navigate to Clusters and select your cluster.

Databricks_Get_Host_and_URL1

...then copy and save your host and http path.

Databricks_Get_Host_and_URL2


Connect Databricks Interactive Cluster

Let's start by selecting + Database — have a look at Select a Database if you need help wth this step.

...then, in the Connect a database window, scroll down and select the Supported Databases field.

In the drop-down list, select Databricks Interactive Cluster.

Select_Interactive_Cluster

Define Display Name and URI

In the Display Name field, enter a database nickname for display in the Preset environment.

In the SQLAlchemy URI field, enter the unique URI based on the following syntax, being careful to enter the relevant token, host, and database name details.

databricks+pyhive://token:{access token}@{server hostname}:{port}/{database name}

The screen should look as follows:

Show_Interactive_Cluster_URI

Provide Additional Parameters

Next, select the Advanced tab and expand the Other panel.

In the Engine Parameters text-entry field, enter the following — be sure to enter the relevant http path retrieved earlier.

{"connect_args": {"http_path": "sql/protocolv1/o/****"}}

The screen should look similar to the following:

Databricks_Engine_Params1

Make the Connection

Next, navigate back to the Basic tab and then select Test Connection.

A notification message will appear indicating success or failure. If the test worked, then go ahead and select Connect to finalize the database connection.

Great work! Below please find the instructions for connecting to a Databricks SQL Endpoint.


Connect Databricks SQL Endpoint

Let's start by selecting + Database — have a look at Select a Database if you need help wth this step.

...then, in the Connect a database window, scroll down and select the Supported Databases field.

In the drop-down list, select Databricks SQL Endpoint.

Select_SQL_Endpoint

Define Display Name and URI

In the Display Name field, enter a database nickname for display in the Preset environment.

In the SQLAlchemy URI field, enter the unique URI based on the following syntax, being careful to enter the relevant token, host, and database name details.

databricks+pyodbc://token:{access token}@{server hostname}:{port}/{database name}

The screen should look as follows:

Show_SQL_Endpoint_URI

Provide Additional Parameters

Next, select the Advanced tab and expand the Other panel.

In the Engine Parameters text-entry field, enter the following: — be sure to enter the relevant http path retrieved earlier.

{"connect_args": {"http_path": "sql/protocolv1/o/****", "driver_path": "/opt/simba/spark/lib/64/libsparkodbc_sb64.so"}}

Reminder

Only replace the http path (i.e., replace the sql/protocolv1/o/**** text with the http path you retrieved earlier in Step 2 when Retrieving Databricks Information). Do not make any changes to the driver path.

Databricks_Engine_Params1

Make the Connection

Next, navigate back to the Basic tab and then select Test Connection.

A notification message will appear indicating success or failure. If the test worked, then go ahead and select Connect to finalize the database connection.

Great work!


Was this article helpful?

What's Next