How to Access Your Platform's Usage Data from Python

Install the delta-sharing library, build a profile file from your token, list the tables you can read, and load one into a Pandas DataFrame.

2 min read

Many data/business analysts use Python for their day-to-day analysis. Our data is also accessible via Python. Follow the steps below in order.

To get access, please reach out to your account manager.

How to enable access and copy your token

  1. Go to the Settings menu for Workspace administrators, or the Account/Administration menu for Client-space administrators.
  1. Generate the token by clicking the Configure connection button.
  1. Copy your token into your tool, or into a separate file (depending on the connection type needed).

If you suspect your token has been compromised:

  • Regenerate it using the Refresh button.
  • Delete it using the Delete button.

How to create a profile file

The profile file is a JSON file containing your token information.

  1. Create a text file (e.g. via Notepad).
  1. Paste your token into it.
  1. Save the file with a .json extension.

How to set up Delta Sharing for Python

  1. Install the Delta Sharing library.
    The !pip install syntax below is Jupyter notebook shorthand for running a shell command from a notebook cell. In a plain terminal, drop the leading !.
    !pip install delta-sharing pandas
  1. Import it.
    import delta_sharing

How to access your data

Point Python at your profile file to retrieve your connection information:

profile_file = 'path'
sharing_client = delta_sharing.SharingClient(profile_file)

How to check which tables you have access to

You may want to check the list of tables you can access:

shares = sharing_client.list_shares()
print(shares)
for share in shares:
    schemas = sharing_client.list_schemas(share)
    for schema in schemas:
        tables = sharing_client.list_tables(schema)
        for table in tables:
            print(f'name = {table.name}, share = {table.share}, schema = {table.schema}')

The result of this step will look something like:

[Share(name='ccfe0e34-1bac-3425-9655-56c9d93b03be--852d8eaf-7529-455b-a34k-8d666aeb2938_platform_aggregated_usage')]

name = platform_aggregated_usage, share = ccfe0e34-1bac-3425-9655-56c9d93b03be--852d8eaf-7529-455b-a34k-8d666aeb2938_platform_aggregated_usage, schema = datagalaxy

How to retrieve your data

Load the table into a Pandas DataFrame:

# Specify the table URL
table_url = "<share>.<schema>.<name>"

# Load the table into a Pandas DataFrame
df = delta_sharing.load_as_pandas(f"{profile_file}#{table_url}")

# Preview the data
df

We're preparing a sample Python script to simplify this process.

Once you have your dataframe, you can follow your usual Python analysis workflow.

Attachment: How_to_connect_data_with_Python.py (881 Bytes). Needs manual re-upload — not carried over by this migration.

Read more

Related articles

Was this page helpful?