Skip to main content

Download a file

This recipe downloads a file from a Unity Catalog volume using the Databricks SDK for Python.

Code snippet

app.py
from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

download_file_path = "/Volumes/catalog/schema/volume_name/file.csv"
response = w.files.download(download_file_path)
file_data = response.contents.read()
file_name = os.path.basename(download_file_path)

Resources

Permissions

Your app service principal needs the following permissions:

  • USE CATALOG on the volume's catalog
  • USE SCHEMA on the volume's schema
  • READ VOLUME on the volume

See Privileges required for volume operations for more information.

Dependencies

requirements.txt
databricks-sdk
dash