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



Create ETL applications and real-time data pipelines for Workday 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 Workday and the petl framework, you can build Workday-connected applications and pipelines for extracting, transforming, and loading Workday data. This article shows how to connect to Workday with the CData Python Connector and use petl and pandas to extract, transform, and load Workday data.

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

About Workday Data Integration

CData provides the easiest way to access and integrate live data from Workday. Customers use CData connectivity to:

  • Access the tables and datasets you create in Prism Analytics Data Catalog, working with the native Workday data hub without compromising the fidelity of your Workday system.
  • Access Workday Reports-as-a-Service to surface data from departmental datasets not available from Prism and datasets larger than Prism allows.
  • Access base data objects with WQL, REST, or SOAP, getting more granular, detailed access but with the potential need for Workday admins or IT to help craft queries.

Users frequently integrate Workday with analytics tools such as Tableau, Power BI, and Excel, and leverage our tools to replicate Workday data to databases or data warehouses. Access is secured at the user level, based on the authenticated user's identity and role.

For more information on configuring Workday to work with CData, refer to our Knowledge Base articles: Comprehensive Workday Connectivity through Workday WQL and Reports-as-a-Service & Workday + CData: Connection & Integration Best Practices.


Getting Started


Connecting to Workday Data

Connecting to Workday 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.

To connect to Workday, users need to find the Tenant and BaseURL and then select their API type.

Obtaining the BaseURL and Tenant

To obtain the BaseURL and Tenant properties, log into Workday and search for "View API Clients." On this screen, you'll find the Workday REST API Endpoint, a URL that includes both the BaseURL and Tenant.

The format of the REST API Endpoint is: https://domain.com/subdirectories/mycompany, where:

  • https://domain.com/subdirectories/ is the BaseURL.
  • mycompany (the portion of the url after the very last slash) is the Tenant.
For example, in the REST API endpoint https://wd3-impl-services1.workday.com/ccx/api/v1/mycompany, the BaseURL is https://wd3-impl-services1.workday.com and the Tenant is mycompany.

Using ConnectionType to Select the API

The value you use for the ConnectionType property determines which Workday API you use. See our Community Article for more information on Workday connectivity options and best practices.

APIConnectionType Value
WQLWQL
Reports as a ServiceReports
RESTREST
SOAPSOAP

Authentication

Your method of authentication depends on which API you are using.

  • WQL, Reports as a Service, REST: Use OAuth authentication.
  • SOAP: Use Basic or OAuth authentication.

See the Help documentation for more information on configuring OAuth with Workday.

After installing the CData Workday Connector, follow the procedure below to install the other required modules and start accessing Workday 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 Workday 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.workday as mod

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

cnxn = mod.connect("User=myuser;Password=mypassword;Tenant=mycompany_gm1;BaseURL=https://wd3-impl-services1.workday.com;ConnectionType=WQL;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")")

Create a SQL Statement to Query Workday

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

sql = "SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM Workers WHERE Legal_Name_Last_Name = 'Morgan'"

Extract, Transform, and Load the Workday Data

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

Loading Workday Data into a CSV File

table1 = etl.fromdb(cnxn,sql)

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

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

In the following example, we add new rows to the Workers table.

Adding New Rows to Workday

table1 = [ ['Worker_Reference_WID','Legal_Name_Last_Name'], ['NewWorker_Reference_WID1','NewLegal_Name_Last_Name1'], ['NewWorker_Reference_WID2','NewLegal_Name_Last_Name2'], ['NewWorker_Reference_WID3','NewLegal_Name_Last_Name3'] ]

etl.appenddb(table1, cnxn, 'Workers')

With the CData Python Connector for Workday, you can work with Workday 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 Workday to start building Python apps and scripts with connectivity to Workday 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.workday as mod

cnxn = mod.connect("User=myuser;Password=mypassword;Tenant=mycompany_gm1;BaseURL=https://wd3-impl-services1.workday.com;ConnectionType=WQL;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")")

sql = "SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM Workers WHERE Legal_Name_Last_Name = 'Morgan'"

table1 = etl.fromdb(cnxn,sql)

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

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

table3 = [ ['Worker_Reference_WID','Legal_Name_Last_Name'], ['NewWorker_Reference_WID1','NewLegal_Name_Last_Name1'], ['NewWorker_Reference_WID2','NewLegal_Name_Last_Name2'], ['NewWorker_Reference_WID3','NewLegal_Name_Last_Name3'] ]

etl.appenddb(table3, cnxn, 'Workers')

Ready to get started?

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

 Download Now

Learn more:

Workday Icon Workday Python Connector

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