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



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

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

Connecting to Oracle Eloqua Data

Connecting to Oracle Eloqua 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.

There are two authentication methods available for connecting to Oracle Eloqua: Login and OAuth. The Login method requires you to have the Company, User, and Password of the user.

If you do not have access to the username and password or do not wish to require them, you can use OAuth authentication. OAuth is better suited for allowing other users to access their own data. Using login credentials is better suited for accessing your own data.

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

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

cnxn = mod.connect("User=user;Password=password;Company=CData;")

Create a SQL Statement to Query Oracle Eloqua

Use SQL to create a statement for querying Oracle Eloqua. In this article, we read data from the Campaign entity.

sql = "SELECT Name, ActualCost FROM Campaign WHERE ShipCity = 'New York'"

Extract, Transform, and Load the Oracle Eloqua Data

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

Loading Oracle Eloqua Data into a CSV File

table1 = etl.fromdb(cnxn,sql)

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

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

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

Adding New Rows to Oracle Eloqua

table1 = [ ['Name','ActualCost'], ['NewName1','NewActualCost1'], ['NewName2','NewActualCost2'], ['NewName3','NewActualCost3'] ]

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

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

cnxn = mod.connect("User=user;Password=password;Company=CData;")

sql = "SELECT Name, ActualCost FROM Campaign WHERE ShipCity = 'New York'"

table1 = etl.fromdb(cnxn,sql)

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

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

table3 = [ ['Name','ActualCost'], ['NewName1','NewActualCost1'], ['NewName2','NewActualCost2'], ['NewName3','NewActualCost3'] ]

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

Ready to get started?

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

 Download Now

Learn more:

Oracle Eloqua Icon Eloqua Python Connector

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