- Run SQL queries against your warehouse data
- List and manage SQL warehouses
- List clusters in your Databricks workspace
- Build live dashboards that query data in real time
Common use cases and example apps
How Databricks connections work
The Databricks connector uses service principal authentication (M2M OAuth). Instead of connecting as an individual user, you create a service principal in Databricks with access to specific tables and views, then provide its credentials to Lovable.What this means for data access
The service principal’s permissions determine what data is available to everyone who uses that connection. Lovable does not filter results based on the individual user’s Databricks permissions. For example, if you create a service principal with access to HR tables, everyone with access to that connection in Lovable can query HR data. Recommended approach: one service principal per access role. Create separate service principals scoped to different data:databricks-engineering: full warehouse access, only engineers get this connection in Lovabledatabricks-sales: pipeline and revenue tables only, sales team gets this connectiondatabricks-company: company-wide safe metrics, everyone gets this connection
How to connect Databricks
Who can create Databricks connections depends on your plan and workspace settings. App + chat connectors are available by default on Free, Pro, and Business plans. On Enterprise plans they are effectively disabled at first: Who can create connections and clients defaults to No one until an admin changes it.Prerequisites
Before connecting, make sure you have:- A Databricks workspace with at least one SQL warehouse
- A service principal configured in Databricks with an OAuth secret (see Databricks M2M OAuth setup)
- The service principal’s client ID and client secret
- Your Databricks workspace URL (for example,
https://dbc-abc123.cloud.databricks.com) - Permission to create connections in your Lovable workspace (see Who can create connections and clients)
- Network access from Lovable to your Databricks workspace, if the workspace restricts inbound traffic
Step 1: Configure a service principal in Databricks
If you haven’t already set up a service principal with an OAuth secret, follow these steps in Databricks. For the full reference, see Databricks M2M OAuth setup.Create a service principal
- AWS: accounts.cloud.databricks.com
- Azure: accounts.azuredatabricks.net
- GCP: accounts.gcp.databricks.com
docs.databricks.com, so translate the links on this page when you are on Azure.Assign it to your workspace
Grant it access to a SQL warehouse
Generate an OAuth secret
- In your Databricks workspace, select your username in the top-right corner and choose Settings.
- Go to Identity and access, then find Service principals and click Manage.
- Select your service principal and open the Secrets tab.
- Click Generate secret, choose an expiry period (maximum 730 days), and click Generate.
- Copy both the Client ID and Client secret immediately. The secret is only shown once. It cannot be retrieved after you close this dialog.
Grant it access to your data
SELECT on a table does nothing without USE CATALOG on its catalog and USE SCHEMA on its schema. Only a catalog owner, or someone with MANAGE on the catalog, can grant USE CATALOG, so you may need to ask them. For the full least-privilege setup, see Restrict a connection to read-only.Find your Workspace URL
- AWS:
https://dbc-a1b2345c-d6e7.cloud.databricks.com - Azure:
https://adb-5555555555555555.19.azuredatabricks.net. You can also select the workspace resource in the Azure portal and read its URL field. - GCP:
https://8757561887652360.0.gcp.databricks.com
Step 2: Set up Databricks connection
Set up the Databricks connection in Lovable.Navigate to Databricks connector
Add a new connection
Name the connection
Databricks Engineering or Databricks Sales). Use a name that reflects the access level of the service principal.Enter your credentials
- Workspace URL: your Databricks workspace URL (for example,
https://dbc-abc123.cloud.databricks.com) - Client ID: the service principal’s OAuth client ID
- Client secret: the service principal’s OAuth client secret
Choose who can use this connection
- Only you (default): leave the access list as is; only you can use the connection and its associated data.
- Invite specific people: add workspace members by email; only you and the people you add can use the connection and its associated data.
- Invite entire workspace: click Invite entire workspace to make the connection available to everyone in your Lovable workspace.
Connect
Restrict a connection to read-only
The connector forwards whatever your app sends. It applies no method or path allowlist, so any Databricks REST path and any HTTP verb reaches your workspace, including aPOST to /api/2.0/sql/statements carrying DROP TABLE. Unity Catalog privileges are the control that works: grant the service principal SELECT and nothing more.
Grant read-only privileges in Unity Catalog
MANAGE on the catalog. Name the principal with its Application ID in backticks, not its display name:GRANT SELECT ON SCHEMA covers every current and future table and view in the schema. Grant SELECT ON TABLE main.analytics.orders instead when you want to name individual tables. Repeat the statements for each schema your app reads.Give it a dedicated warehouse
Keep one service principal per access role
Building a semantic layer
Every Databricks use case benefits from a semantic layer: a shared definition of what your key metrics mean, which tables to use, and what assumptions they carry. What counts as a “daily active user”? How is MRR calculated? Which view should be used for churn, and does it exclude trials? Without this shared context, each app or dashboard risks computing the same metric differently.If you already have a semantic layer
If your Databricks workspace already has a semantic layer (for example, dbt metrics, Unity Catalog tags, or a YAML definitions file), point Lovable to it:If you don’t have one yet
You can build a semantic layer quickly in Lovable using a dedicated project. Create a new project, connect it to Databricks, and ask the agent to explore your warehouse and draft definitions:Limitations
- A service principal connection has no per-user data scoping. Everyone using the connection sees the same data, the service principal’s data. Create separate service principals per access role, or use the Databricks app user connector so each end user queries under their own Databricks login and permissions.
- No enforced read-only access. The connector applies no method or path allowlist, so a connection runs whatever SQL its service principal is allowed to run. Scope it with Unity Catalog grants. See Restrict a connection to read-only.
- No automatic caching. Query results are not cached by default. You can ask Lovable to add caching logic to your app at your chosen interval.
- Connection access is not enforced after publishing. Connection-level access decides who can build with the connection, not who can visit the published app. Who can visit is a separate, publish-time control: on Business and Enterprise plans, set the site’s visibility to Workspace or Custom so visitors have to sign in, and set a workspace-wide default in Workspace settings → Privacy & security → Default website access. See website access control.
- Customer-managed cost controls. Lovable does not impose query cost caps, and neither do Databricks budgets: they scope to your account, workspaces, or resource tags, and they only send email alerts, with up to a 24 hour delay. The controls that actually limit a warehouse are Auto stop, a small Cluster Size, and a
STATEMENT_TIMEOUT. Set the timeout for the whole workspace in Settings → Compute → SQL warehouses → SQL Configuration Parameters, since the system default is 172800 seconds (2 days). Per-warehouse timeouts exist but are in Beta and settable only through the SQL warehouses API.
Manage your connection
Connections are managed from Connectors: select , then open the connection.- Unlink projects to remove access from specific projects while keeping the connection available for others. See Unlink projects from a connection for the steps.
- Delete the connection to remove it from the workspace entirely. Deleting is permanent. It removes the credentials from all linked projects, and app features that use stop working until a new connection is added. See Delete a connection for the steps and who can delete.
FAQ
Does Lovable enforce my Databricks permissions?
Does Lovable enforce my Databricks permissions?
What if someone runs an expensive query?
What if someone runs an expensive query?
STATEMENT_TIMEOUT so a runaway query is halted well before the 172800 second (2 day) system default. Databricks budgets help you notice overspend but do not stop it: they send email alerts and cannot cap a SQL warehouse.Is my data cached or stored in Lovable?
Is my data cached or stored in Lovable?
What happens when I publish an app that queries Databricks?
What happens when I publish an app that queries Databricks?
Can someone leak the Databricks credentials?
Can someone leak the Databricks credentials?
Troubleshooting
The connection verifies, but every query fails with HTTP 403
The connection verifies, but every query fails with HTTP 403
GET 2.0/preview/scim/v2/Me request. That call proves the service principal exists and that its OAuth secret works, and nothing more. It succeeds even when the principal holds no warehouse permission and no table grants, so a connection can report success and then return 403 on its first real query.Work back through the grants in Step 1:- The principal has no Can use on the warehouse. Grant it under SQL Warehouses → (your warehouse) → kebab menu → Permissions.
- The principal is missing Unity Catalog privileges. It needs
USE CATALOG,USE SCHEMA, andSELECT, and all three are required. Check what it already holds withSHOW GRANTS `<application-id>` ON CATALOG main;. - The principal was never assigned to the workspace, or lacks the Databricks SQL access entitlement.
The connection fails immediately with an authentication error
The connection fails immediately with an authentication error
The connection cannot reach Databricks at all
The connection cannot reach Databricks at all
Queries time out or a warehouse never wakes up
Queries time out or a warehouse never wakes up
STATEMENT_TIMEOUT in Settings → Compute → SQL warehouses → SQL Configuration Parameters.