A VS Code extension that transforms Databricks .py files into interactive notebooks with SQL execution, rich DataFrame display, and multi-profile authentication.
- Run Python & SQL cells directly against your Databricks cluster
- Serverless compute support - no cluster management needed
- Persistent kernel state - variables persist across cell executions like Jupyter
- Interactive tables for Spark DataFrame results
- Column sorting and resizing for easy data exploration
- Scrollable output for large query results
- Formatted display - automatic
spark.sql()wrapping for SQL cells
- Switch between Databricks profiles with a single click
- Status bar indicator showing current active profile
- Automatic kernel restart on profile change
- Workspace-level persistence - remembers your selection per project
- Visual cell separation with proper boundaries
- Rendered Markdown with full formatting support
- Syntax highlighting for Python, SQL, Scala, R, and Shell
- Magic command support -
%md,%sql,%python,%pip,%sh,%run - Cell titles via
DBTITLEmetadata - Round-trip editing - preserves Databricks format on save
| Cell Type | Magic Command | Description |
|---|---|---|
| Python | (default) | Default Python code cells |
| Markdown | %md |
Rendered markdown content |
| SQL | %sql |
SQL queries with syntax highlighting |
| Shell | %sh |
Shell/bash commands |
| Run | %run |
Execute other notebooks |
| Pip | %pip |
Package installation |
This extension requires the following VS Code extensions (you'll be prompted to install them):
- Python - For Python kernel execution
- Databricks - For workspace configuration and authentication
Important: Databricks Connect Version Requirement
For serverless compute support, you must use Databricks Connect version 17.2 or earlier. Version 17.3+ does not support serverless compute.
# Install the correct version in your project's virtual environment
pip install "databricks-connect<=17.2"- Go to Latest Release
- Download the
.vsixfile - In VS Code:
Ctrl+Shift+Pβ "Extensions: Install from VSIX..." - Select the downloaded
.vsixfile - Install the required dependencies when prompted
-
Clone the repository and build:
bash build.sh
-
Install the generated
.vsixfile (see above)
Search for "Databricks Notebook Studio" in the VS Code Extensions Marketplace.
-
Right-click menu: Right-click on a
.pyfile in the Explorer and select "Open as Databricks Notebook" -
Command Palette: Open a
.pyfile, then useCtrl+Shift+Pand type "Open as Databricks Notebook" -
Auto-detection: When opening a file that starts with
# Databricks notebook source, you'll be prompted to open it as a notebook
The extension supports managing multiple Databricks authentication profiles from your ~/.databrickscfg file.
- Status Bar: Click the cloud icon in the status bar (bottom right) showing your current profile
- Command Palette: Use
Ctrl+Shift+Pand type "Select Databricks Profile" - Quick Pick: Choose from the list of available profiles with host information
The status bar shows:
$(cloud) profile-name- Profile is selected and active$(cloud) No Profile- No profile selected (yellow warning)$(cloud) No Config- No~/.databrickscfgfile found (red error)
Recommended: Use the Databricks Extension (Required Dependency)
The easiest way to configure profiles is through the official Databricks extension for VS Code:
- Install the Databricks extension (automatically prompted as a dependency)
- Open Command Palette (
Ctrl+Shift+P) β "Databricks: Configure workspace" - Follow the authentication flow to log in to your Databricks workspace
For detailed setup instructions, see the Databricks Extension Quickstart Guide.
The Databricks extension automatically:
- Creates and manages your
~/.databrickscfgfile with profile configurations - Generates and refreshes OAuth tokens in
~/.databricks/token-cache.json - Enables seamless auto-sync between local files and Databricks workspace
This integration allows the Databricks Notebook Studio to automatically authenticate with your configured profiles without manual token management.
Alternative: Databricks CLI
You can also configure profiles using the Databricks CLI:
# Login to Databricks (creates/updates profile)
databricks auth login --host https://your-workspace.cloud.databricks.com
# Login with a specific profile name
databricks auth login --host https://prod.cloud.databricks.com --profile prodExample ~/.databrickscfg:
[DEFAULT]
host = https://dev.cloud.databricks.com
auth_type = databricks-cli
[prod]
host = https://prod.cloud.databricks.com
auth_type = databricks-cliWhen you switch profiles:
- The extension updates the environment variable for the Python kernel
- Any running kernels are automatically restarted with the new profile
- Your selection is saved per workspace
Configure the extension in VS Code settings (Cmd+, or Ctrl+,):
| Setting | Default | Description |
|---|---|---|
databricks-notebook.autoOpenNotebooks |
false |
Automatically open detected Databricks notebooks in notebook view |
databricks-notebook.showNotification |
true |
Show notification prompt when a Databricks notebook is detected |
databricks-notebook.defaultProfile |
"" |
Default Databricks profile to use on startup (leave empty to remember last selection) |
databricks-notebook.showProfileInStatusBar |
true |
Show the current Databricks profile in the status bar |
databricks-notebook.pythonExecutionTimeout |
60000 |
Timeout for Python cell execution in milliseconds |
databricks-notebook.dataDisplayLimit |
100 |
Maximum number of rows to display for DataFrames (Spark and Pandas). Range: 1-100,000 |
π‘ Tip: You can change the data display limit directly in VS Code settings UI:
- Press
Ctrl+,(Windows/Linux) orCmd+,(Mac)- Search for "Databricks data display"
- Adjust the numeric value (1-100,000)
Example settings.json:
{
"databricks-notebook.autoOpenNotebooks": true,
"databricks-notebook.showNotification": true,
"databricks-notebook.defaultProfile": "prod",
"databricks-notebook.showProfileInStatusBar": true,
"databricks-notebook.dataDisplayLimit": 100
}Recommended configurations:
-
Manual mode (default):
autoOpenNotebooks: false,showNotification: true- You'll see a prompt asking if you want to open as notebook
-
Auto mode:
autoOpenNotebooks: true- Databricks
.pyfiles automatically open as notebooks
- Databricks
-
Silent mode:
autoOpenNotebooks: false,showNotification: false- No automatic behavior; use right-click or Command Palette to open as notebook
Note: After changing these settings, you may need to reload VS Code (
Cmd+Shift+Pβ "Developer: Reload Window") for the changes to take effect on already-opened files.
Databricks notebooks exported as .py files follow this format:
# Databricks notebook source
print("Python cell")
# COMMAND ----------
# MAGIC %md
# MAGIC # Markdown Heading
# MAGIC Some markdown content
# COMMAND ----------
# MAGIC %sql
# MAGIC SELECT * FROM table- Node.js 18+
- npm or yarn
# Clone the repository
git clone <repository-url>
cd databricks-notebook-studio
# Install dependencies
npm install
# Compile
npm run compile
# Watch mode (for development)
npm run watch- Open the project in VS Code
- Press
F5to start debugging - A new VS Code window (Extension Development Host) will open
- Open a Databricks
.pyfile to test
npm run test:unitnpm run packageThis creates a production-ready build in the dist/ folder.
src/
βββ extension.ts # Extension entry point
βββ serializer.ts # NotebookSerializer implementation
βββ parser.ts # Databricks .py file parser
βββ controller.ts # NotebookController (optional execution)
βββ types.ts # TypeScript interfaces
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
npm run test:unit - Submit a pull request
MIT
- Inspired by Databricks' notebook format and VS Code's Notebook API
- Built with VS Code Extension API