How to Build an ETL App for Talkdesk Data in Python with CData

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Create ETL applications and real-time data pipelines for Talkdesk data in Python with petl.

The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for Talkdesk and the petl framework, you can build Talkdesk-connected applications and pipelines for extracting, transforming, and loading Talkdesk data. This article shows how to connect to Talkdesk with the CData Python Connector and use petl and pandas to extract, transform, and load Talkdesk data.

With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Talkdesk data in Python. When you issue complex SQL queries from Talkdesk, the driver pushes supported SQL operations, like filters and aggregations, directly to Talkdesk and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).

Connecting to Talkdesk Data

Connecting to Talkdesk data looks just like connecting to any relational data source. Create a connection string using the required connection properties. For this article, you will pass the connection string as a parameter to the create_engine function.

Talkdesk uses the OAuth 2.0 Client Credentials grant. There is no browser-based authorization step and no callback URL.

Set the following connection properties:

  • AccountName: The name of your Talkdesk account.
  • Region: The region where your Talkdesk instance is deployed. Supported values are US (default), EU, CA, AU, UK, and FedRamp.
  • OAuthClientId: The Client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The Client Secret assigned to your custom OAuth application.

Creating a Custom OAuth Application

  1. Log in to your Talkdesk account and select OAuth Clients from the navigation menu.
  2. Click Create OAuth Client and give the client a descriptive name.
  3. Set Grant Type to Client Credentials.
  4. Click Add scopes and select the scopes for the data you want to access.
  5. Click Create and copy the Client Id and Client Secret.

When you connect, the driver automatically requests an access token from Talkdesk, caches it, and refreshes it when it expires. Make sure the scopes selected for the application match the views you plan to query, or the token request can fail.

After installing the CData Talkdesk Connector, follow the procedure below to install the other required modules and start accessing Talkdesk through Python objects.

Install Required Modules

Use the pip utility to install the required modules and frameworks:

pip install petl
pip install pandas

Build an ETL App for Talkdesk Data in Python

Once the required modules and frameworks are installed, we are ready to build our ETL app. Code snippets follow, but the full source code is available at the end of the article.

First, be sure to import the modules (including the CData Connector) with the following:

import petl as etl
import pandas as pd
import cdata.talkdesk as mod

You can now connect with a connection string. Use the connect function for the CData Talkdesk Connector to create a connection for working with Talkdesk data.

cnxn = mod.connect("AccountName=myAccount;Region=US;OAuthClientId=myClientId;OAuthClientSecret=myClientSecret;")

Create a SQL Statement to Query Talkdesk

Use SQL to create a statement for querying Talkdesk. In this article, we read data from the Users entity.

sql = "SELECT Id, Name FROM Users WHERE Active = 'true'"

Extract, Transform, and Load the Talkdesk Data

With the query results stored in a DataFrame, we can use petl to extract, transform, and load the Talkdesk data. In this example, we extract Talkdesk data, sort the data by the Name column, and load the data into a CSV file.

Loading Talkdesk Data into a CSV File

table1 = etl.fromdb(cnxn,sql)

table2 = etl.sort(table1,'Name')

etl.tocsv(table2,'users_data.csv')

With the CData Python Connector for Talkdesk, you can work with Talkdesk data just like you would with any database, including direct access to data in ETL packages like petl.

Free Trial & More Information

Download a free, 30-day trial of the CData Python Connector for Talkdesk to start building Python apps and scripts with connectivity to Talkdesk data. Reach out to our Support Team if you have any questions.



Full Source Code


import petl as etl
import pandas as pd
import cdata.talkdesk as mod

cnxn = mod.connect("AccountName=myAccount;Region=US;OAuthClientId=myClientId;OAuthClientSecret=myClientSecret;")

sql = "SELECT Id, Name FROM Users WHERE Active = 'true'"

table1 = etl.fromdb(cnxn,sql)

table2 = etl.sort(table1,'Name')

etl.tocsv(table2,'users_data.csv')

Ready to get started?

Download a free trial of the Talkdesk Connector to get started:

 Download Now

Learn more:

Talkdesk Icon Talkdesk Python Connector

Python Connector Libraries for Talkdesk Data Connectivity. Integrate Talkdesk with popular Python tools like Pandas, SQLAlchemy, Dash & petl.