Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.

cdp-connector

A readonly CDP client for Python. This can be used to execute queries against CDP and load the data into python.

Usage

Installation

Install the package from Pypi using the command

pip install cdp-connector

Quick Start

We have to create an instance of the SalesforceCDPConnection to connect to CDP.

The object can be created as follows:

Using Username and Password

from salesforcecdpconnector.connection import SalesforceCDPConnection
conn = SalesforceCDPConnection(
        'login_url', 
        'user_name', 
        'password', 
        'client_id', 
        'client_secret'
    )

Using OAuth Tokens

from salesforcecdpconnector.connection import SalesforceCDPConnection
conn = SalesforceCDPConnection(login_url, 
       client_id='<client_id>', 
       client_secret='<client_secret>', 
       core_token='<core token>'
       refresh_token='<refresh_token>'
   )

Once the connection object is created the queries can be executed using cursor as follows

cur = conn.cursor()
cur.execute('<query>')
results = cur.fetchall()

The query results can also be directly extracted as a pandas dataframe

dataframe = conn.get_pandas_dataframe('<query>')

Creating a connected App

  1. Log in to salesforce as an admin. In the top right corner, click on the gear icon and go to step
  2. In the left hand side, under Platform Tools, go to Apps > App Manager
  3. Click on New Connected App
  4. Fill in the required Basic Information fields.
  5. Under API (Enable OAuth Settings)
    1. Click on the checkbox to Enable OAuth Settings.
    2. Provide a callback URL.
    3. In the Selected OAuth Scopes, make sure that refresh_token, api, cdp_query_api, cdp_profile_api is selected.
    4. Click on Save to save the connected app
  6. From the page that opens up, click on the Manage Consumer Details to find your client id and client secret

Fetching Refresh Token

  1. From the connected app, note down the below details:

    • Client Id
    • Client Secret
    • Callback URL
  2. Obtain the code

    1. From browser, go to the below url.
    <LOGIN_URL>/services/oauth2/authorize?response_type=code&client_id=<client_id>&redirect_uri=<callback_url>
    
    1. This will redirect you to the callback url. The redirected url will be of the form <callback url>?code=<CODE>
    2. Extract the CODE from the address bar to be used in next step. Check the network tab of browser if the addressbar doesn't show this.
  3. Get core and refresh tokens

    1. Make a post call using curl or postman to the below url using the code retrieved in previous step.
    <LOGIN_URL>/services/oauth2/token?code=<CODE>&grant_type=authorization_code&client_id=<clientId>&client_secret=<clientSecret>&redirect_uri=<callback_uri>
    
    1. The response to the above post call will be a json with access_token and refresh_token

Metadata

Release files for cdp-connector 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdp-connector 1.0.2
File Size Uploaded
cdp-connector-1.0.2.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdp-connector 1.0.2
File Interpreter ABI Platform
cdp_connector-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / cdp-connector-1.0.2.tar.gz

Download URL cdp-connector-1.0.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a82beb90c72579a4786309969bd70c024153cddda6f8c4fe0239a6469065e062
BLAKE2b-256 checksum
How to use checksums
994e0b068d266637aeb8029264a2bd3e5d719985820862e2a7623a2ff2e996fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / cdp_connector-1.0.2-py3-none-any.whl

Download URL cdp_connector-1.0.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bfccd5072b6e596d261148c881cf283b9d0bbdd9c08a0ce4dd833ea2a59ef3d
BLAKE2b-256 checksum
How to use checksums
1b7d8e2ccc627a1307e8a1b8cf3d0eeda49e29eabe54aafe54a4b5a3e0a1ef49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page