Metadata-Version: 2.1
Name: liveramp-clean-room
Version: 0.3.2
Summary: This is a python client that provides high level functions for interacting with liveramp's clean room.
Author: Datahub Eng
Author-email: datahub_ops@liveramp.com
Requires-Python: >=3.7.1,<4.0.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: Jinja2 (>=3.1.2,<4.0.0)
Requires-Dist: backoff (>=2.2.1,<3.0.0)
Requires-Dist: cachetools (>=5.0.0,<6.0.0)
Requires-Dist: numpy (>=1.3,<2.0)
Requires-Dist: pandas (>=1.3,<2.0)
Requires-Dist: pyarrow (==9.0.0)
Requires-Dist: pytest (>=7.4.2,<8.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: sqlglot (>=18.1.0,<19.0.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Description-Content-Type: text/markdown

# 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


```bash
pip install liveramp_clean_room
```


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


```python
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
---
```python
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


