Databricks CLI

0.18.0 · deprecated · verified Sun Apr 05

The `databricks-cli` Python package provided a command-line interface for Databricks. As of version 0.18.0, this package is deprecated. Users are advised to migrate to the new Databricks CLI (an independent executable) for command-line operations and to the `databricks-sdk-py` Python SDK for programmatic interactions. Databricks plans no further support or new feature work for this legacy package.

Warnings

Install

Imports

Quickstart

This quickstart first demonstrates how to use the recommended `databricks-sdk` for Python to programmatically list Databricks clusters, assuming authentication via environment variables (`DATABRICKS_HOST`, `DATABRICKS_TOKEN`). It also highlights typical command-line usage for both the legacy `databricks-cli` and the recommended new `databricks` CLI executable. Users should migrate programmatic logic to `databricks-sdk` and command-line scripts to the new `databricks` CLI.

# Authenticate via environment variables (recommended for quickstart)
# export DATABRICKS_HOST="https://<your-workspace-url>"
# export DATABRICKS_TOKEN="dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# --- Old databricks-cli usage (deprecated) ---
# The primary use was via the command line, e.g.:
# databricks clusters list

# --- New Databricks SDK for Python (recommended for programmatic access) ---
import os
from databricks.sdk import WorkspaceClient

# The SDK automatically uses DATABRICKS_HOST and DATABRICKS_TOKEN environment variables
w = WorkspaceClient(
    host=os.environ.get('DATABRICKS_HOST', ''),
    token=os.environ.get('DATABRICKS_TOKEN', '')
)

# Example: List clusters using the new SDK
print("Listing Databricks clusters (using new SDK):")
for c in w.clusters.list():
    print(f"  - {c.cluster_name} ({c.cluster_id})")

# --- New Databricks CLI executable (recommended for command-line access) ---
# After installing the new CLI executable (not this Python package):
# databricks auth login --host https://<your-workspace-url>
# databricks clusters list

view raw JSON →