Extract, Transform, and Load Epicor ERP Data in Python

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Epicor ERP Python Connector

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

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

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

Connecting to Epicor ERP Data

Connecting to Epicor ERP 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 successfully connect to your ERP instance, you must specify the following connection properties:

  • Url:the URL of the server hosting your ERP instance. For example, https://myserver.EpicorSaaS.com
  • ERPInstance: the name of your ERP instance.
  • User: the username of your account.
  • Password: the password of your account.
  • Service: the service you want to retrieve data from. For example, BaqSvc.

In addition, you may also set the optional connection properties:

  • ApiKey: An optional key that may be required for connection to some services depending on your account configuration.
  • ApiVersion: Defaults to v1. May be set to v2 to use the newer Epicor API.
  • Company: Required if you set the ApiVersion to v2.

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

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

cnxn = mod.connect("Service=Erp.BO.CustomerSvc;ERPInstance=MyInstance;URL=https://myaccount.epicorsaas.com;User=username;Password=password;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")")

Create a SQL Statement to Query Epicor ERP

Use SQL to create a statement for querying Epicor ERP. In this article, we read data from the Customers entity.

sql = "SELECT CustNum, Company FROM Customers WHERE CompanyName = 'CompanyName'"

Extract, Transform, and Load the Epicor ERP Data

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

Loading Epicor ERP Data into a CSV File

table1 = etl.fromdb(cnxn,sql)

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


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

Adding New Rows to Epicor ERP

table1 = [ ['CustNum','Company'], ['NewCustNum1','NewCompany1'], ['NewCustNum2','NewCompany2'], ['NewCustNum3','NewCompany3'] ]

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

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

cnxn = mod.connect("Service=Erp.BO.CustomerSvc;ERPInstance=MyInstance;URL=https://myaccount.epicorsaas.com;User=username;Password=password;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")")

sql = "SELECT CustNum, Company FROM Customers WHERE CompanyName = 'CompanyName'"

table1 = etl.fromdb(cnxn,sql)

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


table3 = [ ['CustNum','Company'], ['NewCustNum1','NewCompany1'], ['NewCustNum2','NewCompany2'], ['NewCustNum3','NewCompany3'] ]

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