How to Build an ETL App for JD Edwards Data in Python with CData
The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for JD Edwards and the petl framework, you can build JD Edwards-connected applications and pipelines for extracting, transforming, and loading JD Edwards data. This article shows how to connect to JD Edwards with the CData Python Connector and use petl and pandas to extract, transform, and load JD Edwards data.
With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live JD Edwards data in Python. When you issue complex SQL queries from JD Edwards, the driver pushes supported SQL operations, like filters and aggregations, directly to JD Edwards and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).
Connecting to JD Edwards Data
Connecting to JD Edwards 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.
The driver connects to JD Edwards through your Application Interface Services (AIS) Server. Set the following connection properties:
- URL: The base HTTPS URL of your AIS Server (e.g., https://jde-ais.example.com:8300).
- User: Your JD Edwards username.
- Password: Your JD Edwards password.
- Environment (optional): The JD Edwards environment to use (e.g., PD920 for production or DV920 for development). If not specified, the AIS Server's default environment is used.
- Role (optional): The JD Edwards role for the session. If not specified, the AIS Server's default role is used.
- DeviceName (optional): An identifier for the connecting device or application, used for auditing and logging on the AIS Server.
- Jasserver (optional): The specific Java Application Server (JAS) instance to route requests through, useful in clustered environments.
Choosing Which Data Is Exposed
JD Edwards organizes tables and business views by System Code, and the driver exposes each System Code as its own schema. Use these properties to control which schemas are available:
- DataModel: One or more ERP modules (comma-separated) whose System Codes are exposed as schemas, or All to expose every System Code in the connected instance. Defaults to FinancialManagement.
- SystemCodes: A comma-separated list of additional System Codes to expose alongside those from DataModel (e.g., 42,43).
When you connect, the driver sends your credentials to the AIS Server to obtain a session token and caches it. The driver requests a new token automatically before the session expires.
After installing the CData JD Edwards Connector, follow the procedure below to install the other required modules and start accessing JD Edwards 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 JD Edwards 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.jdedwards as mod
You can now connect with a connection string. Use the connect function for the CData JD Edwards Connector to create a connection for working with JD Edwards data.
cnxn = mod.connect("URL=https://your-jde-environment-app.example.com;User=admin;Password=myPassword;")
Create a SQL Statement to Query JD Edwards
Use SQL to create a statement for querying JD Edwards. In this article, we read data from the AccountsPayable.AccountLedger entity.
sql = "SELECT DocumentNumber, Amount FROM AccountsPayable.AccountLedger WHERE BusinessUnit = '100'"
Extract, Transform, and Load the JD Edwards Data
With the query results stored in a DataFrame, we can use petl to extract, transform, and load the JD Edwards data. In this example, we extract JD Edwards data, sort the data by the Amount column, and load the data into a CSV file.
Loading JD Edwards Data into a CSV File
table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Amount') etl.tocsv(table2,'accountspayable.accountledger_data.csv')
With the CData Python Connector for JD Edwards, you can work with JD Edwards 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 JD Edwards to start building Python apps and scripts with connectivity to JD Edwards 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.jdedwards as mod
cnxn = mod.connect("URL=https://your-jde-environment-app.example.com;User=admin;Password=myPassword;")
sql = "SELECT DocumentNumber, Amount FROM AccountsPayable.AccountLedger WHERE BusinessUnit = '100'"
table1 = etl.fromdb(cnxn,sql)
table2 = etl.sort(table1,'Amount')
etl.tocsv(table2,'accountspayable.accountledger_data.csv')