Deploy a Text-to-SQL AI Agent on Databricks Apps

Deploy the open-source db-agent to Databricks Apps over a built-in sample dataset. The lab then asks a test question through the live app to confirm it works.

Level
Beginner
Duration
About 20 min
Cost
Free tier
Runs on a vendor free plan.
Technologies
Text-to-SQLAI agentsDatabricks AppsUnity CatalogSQL warehouse

What you will build

  • A text-to-SQL agent running as a Databricks App in your own workspace
  • A connection to the built-in samples catalog, so nothing is downloaded
  • A revocable app token stored as a secret
  • A verified end-to-end test question

Prerequisites

  • A Databricks workspace (Free Edition works)
  • The Databricks CLI, logged in with databricks auth login
  • Python 3.9 or newer with pip
  • git installed

Run it

Install once, then launch the lab. Preview the steps first with the dry run. Remove everything when you finish.

pip install 'labagent[rag]'
databricks auth login

# preview the steps without changing anything
labagent launch db-agent --name demo --dry-run

# launch the lab (safe to re-run, it resumes where it stopped)
labagent launch db-agent --name demo --param dataset=bakehouse

# remove only what the lab created
labagent destroy db-agent --name demo

Steps

  1. 1

    Preflight

    Check your login, SQL warehouse, sample data and serving endpoints.

  2. 2

    Fetch db-agent

    Clone the app at a pinned commit so you run the code that was reviewed.

  3. 3

    Create the app token

    Make a revocable token and store it as a secret.

  4. 4

    Deploy the app

    Publish the Databricks App.

  5. 5

    Verify

    Ask a test question through the deployed app.

FAQ

Which data does the agent query?+
The samples catalog every Databricks workspace has. The default dataset is bakehouse. You can pass another, such as tpch, nyctaxi or tpcds_sf1.
Does labagent copy the db-agent code?+
No. It clones db-agent at a pinned commit and deploys it to your workspace.
What happens to the access token when I remove the lab?+
The destroy command revokes the app token and deletes its secret scope.
Does this lab cost money?+
It runs on Databricks Free Edition. Free Edition allows three apps, and apps stop after 24 hours.

Pick how you want to use this lab

Run it free

Use the commands above on your own machine and account.

Go to the commands

Get team access

Private environments for a class or team.

Send us details

Book a corporate workshop

A 30-minute call to scope training for your team.

Book a call
Team access

Run this lab for your team

Tell us the class size and the date. We reply within one business day.

We respect your privacy. No spam, ever.

Related labs