Skip to main content

This is a python client that provides high level functions for interacting with liveramp's clean room.

Project description

Liveramp clean room

This library provides high level functions for interacting with liveramp's clean room API. Whilst users can directly interact with the API, we highly recommend the use of this client as it provides the following benefits:

  • Automatic fetching and efficient caching of access token
  • Automatic fetching of query status with exponential backoff
  • Provides a simple interface for fetching query result as a pandas dataframe
  • Provides user friendly interfaces for interacting with assets and associated permissions
  • Provides clear and intuitive error messages

Pre-Requisites

Credentials File

Use of the client requires an account configured with access to an organization within Data Hub. LiveRamp customers must use a service account for that purpose. A service account credential, in the form of a JSON file, can be generated by a LiveRamp employee and shared securely.

Installation

The Client is hosted on https://pypi.org/project/liveramp-clean-room/ and thus can be installed via

pip install liveramp_clean_room

Once installed the client be instantiated and added to your code as the example below shows:

from liveramp_clean_room import datahub


## Initialize a client
org_id = "00XXX0XXX0XXX00X0XXX000XXX"
credentials_file = "Path to service account file"
proxies = {
    'http': 'http://10.10.1.10:3128',
    'https': 'http://10.10.1.10:1080',
}

client = datahub.Client(org_id, credentials_file, proxies=proxies)

Where org_id is the id of an organization within DataHub and credentials_file is the JSON file location of your service account

proxies is an optional parameter that can be used to specify a proxy server for the client to use. If not specified, the client will not use a proxy server.

Running Queries

To run a query utilize the run_query function. DataHub supports the following query types:

  • Data Manipulation Language (DML)

    SELECT query

  • Data Definition Language (DDL)

    CREATE OR REPLACE FUNCTION/DROP FUNCTION), used to create or drop UDFs, a createdAssetID will be returned in the response.

Example: Run a query and get results

from liveramp_clean_room import datahub


org_id = "00XXX0XXX0XXX00X0XXX000XXX"
credentials_file = "Path to service account file"
client = datahub.Client(org_id, credentials_file)
query_id = client.run_query("select * from schema.mytable")


## Fetch result as a pandas dataframe
dataframe = client.get_result(query_id)

Note that the client returns a Pandas Dataframe

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liveramp_clean_room-0.3.3.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

liveramp_clean_room-0.3.3-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page