![]() |
VOOZH | about |
The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for Certinia and the petl framework, you can build Certinia-connected applications and pipelines for extracting, transforming, and loading Certinia data. This article shows how to connect to Certinia with the CData Python Connector and use petl and pandas to extract, transform, and load Certinia data.
With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Certinia data in Python. When you issue complex SQL queries from Certinia, the driver pushes supported SQL operations, like filters and aggregations, directly to Certinia and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).
Connecting to Certinia 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 several authentication methods available for connecting to Certinia: login credentials, SSO, and OAuth.
Set the User and Password to your login credentials. Additionally, set the SecurityToken. By default, the SecurityToken is required, but you can make it optional by allowing a range of trusted IP addresses.
To disable the security token:
To obtain the security token:
If you do not have access to the user name and password or do not want to require them, use the OAuth user consent flow. See the OAuth section in the Help for an authentication guide.
Set UseSandbox to true (false by default) to use a Certinia sandbox account. Ensure that you specify a sandbox user name in User.
After installing the CData Certinia Connector, follow the procedure below to install the other required modules and start accessing Certinia through Python objects.
Use the pip utility to install the required modules and frameworks:
pip install petl pip install pandas
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.certinia as mod
You can now connect with a connection string. Use the connect function for the CData Certinia Connector to create a connection for working with Certinia data.
cnxn = mod.connect("User=myUser;Password=myPassword;Security Token=myToken;InitiateOAuth=GETANDREFRESH;")
Use SQL to create a statement for querying Certinia. In this article, we read data from the Account entity.
sql = "SELECT BillingState, Name FROM Account WHERE Industry = 'Floppy Disks'"
With the query results stored in a DataFrame, we can use petl to extract, transform, and load the Certinia data. In this example, we extract Certinia data, sort the data by the Name column, and load the data into a CSV file.
table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Name') etl.tocsv(table2,'account_data.csv')
In the following example, we add new rows to the Account table.
table1 = [ ['BillingState','Name'], ['NewBillingState1','NewName1'], ['NewBillingState2','NewName2'], ['NewBillingState3','NewName3'] ] etl.appenddb(table1, cnxn, 'Account')
With the CData Python Connector for Certinia, you can work with Certinia data just like you would with any database, including direct access to data in ETL packages like petl.
Download a free, 30-day trial of the CData Python Connector for Certinia to start building Python apps and scripts with connectivity to Certinia data. Reach out to our Support Team if you have any questions.
import petl as etl
import pandas as pd
import cdata.certinia as mod
cnxn = mod.connect("User=myUser;Password=myPassword;Security Token=myToken;InitiateOAuth=GETANDREFRESH;")
sql = "SELECT BillingState, Name FROM Account WHERE Industry = 'Floppy Disks'"
table1 = etl.fromdb(cnxn,sql)
table2 = etl.sort(table1,'Name')
etl.tocsv(table2,'account_data.csv')
table3 = [ ['BillingState','Name'], ['NewBillingState1','NewName1'], ['NewBillingState2','NewName2'], ['NewBillingState3','NewName3'] ]
etl.appenddb(table3, cnxn, 'Account')
Download a Community License of the Certinia Connector to get started:
Download NowLearn more:
👁 Certinia IconPython Connector Libraries for Certinia Data Connectivity. Integrate Certinia with popular Python tools like Pandas, SQLAlchemy, Dash & petl.