{"library":"databricks-cli","code":"# Authenticate via environment variables (recommended for quickstart)\n# export DATABRICKS_HOST=\"https://<your-workspace-url>\"\n# export DATABRICKS_TOKEN=\"dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n\n# --- Old databricks-cli usage (deprecated) ---\n# The primary use was via the command line, e.g.:\n# databricks clusters list\n\n# --- New Databricks SDK for Python (recommended for programmatic access) ---\nimport os\nfrom databricks.sdk import WorkspaceClient\n\n# The SDK automatically uses DATABRICKS_HOST and DATABRICKS_TOKEN environment variables\nw = WorkspaceClient(\n    host=os.environ.get('DATABRICKS_HOST', ''),\n    token=os.environ.get('DATABRICKS_TOKEN', '')\n)\n\n# Example: List clusters using the new SDK\nprint(\"Listing Databricks clusters (using new SDK):\")\nfor c in w.clusters.list():\n    print(f\"  - {c.cluster_name} ({c.cluster_id})\")\n\n# --- New Databricks CLI executable (recommended for command-line access) ---\n# After installing the new CLI executable (not this Python package):\n# databricks auth login --host https://<your-workspace-url>\n# databricks clusters list\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}