Databricks CLI
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
- breaking This `databricks-cli` Python package is deprecated. It receives no new features or support. For programmatic use, migrate to `databricks-sdk-py`. For command-line use, migrate to the new standalone `databricks/cli` executable. Failure to migrate will result in outdated functionality and potential compatibility issues.
- deprecated Personal Access Token (PAT) authentication for Databricks is deprecated, and basic authentication (username/password) reached End-of-Life on July 10, 2024. New projects should use OAuth machine-to-machine (M2M) or user-to-machine (U2M) authentication.
- gotcha Version 0.18.0 of `databricks-cli` removed the explicit pin on `urllib3 < 2`. While this unblocks newer `urllib3` versions, older environments might encounter compatibility issues if they upgrade `databricks-cli` but retain an old `urllib3` that has breaking changes with other dependencies.
Install
-
pip install databricks-cli -
pip install databricks-sdk -
curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh
Imports
- ApiClient, service
from databricks.sdk import WorkspaceClient # Or, for account-level operations: from databricks.sdk import AccountClient
Quickstart
# 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