| tags | Data Infrastructure |
|---|---|
| description | Connect with Databricks to run data pipelines and advanced analytics seamlessly. |
The Databricks Integration allows your app to connect to Databricks for secure data access, querying, and analytics. Once connected, you can run SQL queries, retrieve results, and power data-driven workflows directly from your app.
With Databricks, your app can:
- Connect securely to your Databricks workspace.
- Run SQL queries or fetch data programmatically.
- Build dashboards and data visualizations on top of your Databricks tables.
- Automate workflows triggered by new or updated data.
- Combine Databricks with AI models for advanced analytics.
import reflex as rx
from reflex_image_zoom import image_zoom1 - Log in to your Databricks Workspace.
2 - Get your DATABRICKS_HOST and DATABRICKS_WAREHOUSE_ID:
- Go to
SQL Warehousesfrom the sidebar. - Select your desired warehouse.
- Click
Connection details. - Copy the Server hostname (this is your DATABRICKS_HOST).
- Copy the HTTP path removing the
/sql/1.0/warehouses/prefix (this is your DATABRICKS_WAREHOUSE_ID).
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_1.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)3 - Get your DATABRICKS_CATALOG and DATABRICKS_SCHEMA:
- Click the SQL Editor from the sidebar.
- Choose the DATABRICKS_CATALOG and DATABRICKS_SCHEMA from the dropdowns as shown below.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_4.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)rx.box(height="2rem")4 - Obtain your authentication credentials:
There are two methods to authenticate your app with Databricks: using a Personal Access Token or via OAuth. Choose one of the methods below to obtain the necessary credentials.
---md tabs
--tab Personal Access Token
- Click on your profile icon → Settings.
- Click Developer.
- Click Manage in Access Tokens.
- Click Generate New Token, provide a name and expiration, then copy it (DATABRICKS_TOKEN).
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_2.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_3.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)-- --tab OAuth
- Open the dropdown in the top right corner and select Manage Account.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_1.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Select
Users and Groups
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_2.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Select the
Service Principalstab and clickAdd Service Principal.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_3.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Fill in the details and click
Add Service Principal.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_4.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Click the
Credentials and Secretstab and clickGenerate Secret.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_5.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Set a lifetime for the secrets and click
Generate.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_6.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)- Copy the generated DATABRICKS_CLIENT_ID and DATABRICKS_CLIENT_SECRET.
rx.el.div(
image_zoom(
rx.image(
src="/ai_builder/integrations/databricks_integration_oauth_7.webp",
class_name="p-2 rounded-md h-auto",
border=f"0.81px solid {rx.color('slate', 5)}",
),
class_name="rounded-md overflow-hidden",
),
class_name="w-full flex flex-col rounded-md cursor-pointer",
)--
- In your app, go to Integrations and Add Databricks.
- Paste your
- DATABRICKS_TOKEN
- DATABRICKS_HOST
- DATABRICKS_WAREHOUSE_ID
- DATABRICKS_CATALOG
- DATABRICKS_SCHEMA
- Click Connect to validate and save your integration.
Once connected, the AI Builder can execute queries directly against your Databricks environment.
- Secure your token: Never expose tokens in public code.
- Permissions: Ensure your token or service account has the required workspace and table permissions.
- Combine with AI: Use query outputs to power models, summaries, or alerts in real time.