Unity Catalog Client

0.4.1 · active · verified Sat Apr 11

The `unitycatalog-client` is the official Python SDK for interacting with Databricks Unity Catalog APIs. It provides programmatic access to manage catalogs, schemas, tables, volumes, and other Unity Catalog assets. Currently at version 0.4.1, it receives frequent updates, often with multiple releases per month, reflecting ongoing development and new feature integration.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `UnityCatalogClient` and list all available catalogs. It relies on `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables for authentication, which must be set for the client to connect successfully.

import os
from unitycatalog_client import UnityCatalogClient

# To run this code, set the following environment variables:
# os.environ['DATABRICKS_HOST'] = 'https://<your-databricks-host>'
# os.environ['DATABRICKS_TOKEN'] = 'dapi...' # A Databricks personal access token

try:
    # The client automatically picks up DATABRICKS_HOST and DATABRICKS_TOKEN
    # from environment variables if not provided explicitly.
    client = UnityCatalogClient()

    print("Attempting to list catalogs in Unity Catalog...")
    catalogs = client.list_catalogs()

    if catalogs:
        print(f"Successfully retrieved {len(catalogs)} catalogs:")
        for catalog in catalogs:
            print(f"- Name: {catalog.name}, Full Name: {catalog.full_name}")
    else:
        print("No catalogs found or accessible.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure DATABRICKS_HOST and DATABRICKS_TOKEN environment variables are set and valid,")
    print("and that your token has permissions to list catalogs.")

view raw JSON →