Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →How to Build an ETL App for Act CRM Data in Python with CData
Create ETL applications and real-time data pipelines for Act CRM 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 Act CRM and the petl framework, you can build Act CRM-connected applications and pipelines for extracting, transforming, and loading Act CRM data. This article shows how to connect to Act CRM with the CData Python Connector and use petl and pandas to extract, transform, and load Act CRM data.
With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Act CRM data in Python. When you issue complex SQL queries from Act CRM, the driver pushes supported SQL operations, like filters and aggregations, directly to Act CRM and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).
Connecting to Act CRM Data
Connecting to Act CRM 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 User and Password properties, under the Authentication section, must be set to valid Act! user credentials. In addition to the authentication values, see the following:
-
Connecting to Act! Premium
In addition to the authentication values, the URL to Act! is also required; for example https://eup1-iis-04.eu.hosted.act.com/.
Additionally, you must specify the ActDatabase you will connect to. This is found by going to the About Act! Premium menu of your account, at the top right of the page, in the ? menu. Use the Database Name in the window that appears.
-
Connecting to Act! Premium Cloud
To connect to your Act! Premium Cloud account, you also need to specify the ActCloudName property. This property is found in the URL address of the Cloud account; for example https://eup1-iis-04.eu.hosted.act.com/ActCloudName/.
Note that retrieving ActCRM metadata can be expensive. It is advised that you set the CacheMetadata property to store the metadata locally.
After installing the CData Act CRM Connector, follow the procedure below to install the other required modules and start accessing Act CRM 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 Act CRM 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.actcrm as mod
You can now connect with a connection string. Use the connect function for the CData Act CRM Connector to create a connection for working with Act CRM data.
cnxn = mod.connect("URL=https://myActCRMserver.com;User=myUser;Password=myPassword;ActDatabase=MyDB;")
Create a SQL Statement to Query Act CRM
Use SQL to create a statement for querying Act CRM. In this article, we read data from the Activities entity.
sql = "SELECT ActivityDisplayName, Subject FROM Activities WHERE Subject = 'Sample subject'"
Extract, Transform, and Load the Act CRM Data
With the query results stored in a DataFrame, we can use petl to extract, transform, and load the Act CRM data. In this example, we extract Act CRM data, sort the data by the Subject column, and load the data into a CSV file.
Loading Act CRM Data into a CSV File
table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Subject') etl.tocsv(table2,'activities_data.csv')
In the following example, we add new rows to the Activities table.
Adding New Rows to Act CRM
table1 = [ ['ActivityDisplayName','Subject'], ['NewActivityDisplayName1','NewSubject1'], ['NewActivityDisplayName2','NewSubject2'], ['NewActivityDisplayName3','NewSubject3'] ] etl.appenddb(table1, cnxn, 'Activities')
With the CData Python Connector for Act CRM, you can work with Act CRM 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 Act CRM to start building Python apps and scripts with connectivity to Act CRM 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.actcrm as mod cnxn = mod.connect("URL=https://myActCRMserver.com;User=myUser;Password=myPassword;ActDatabase=MyDB;") sql = "SELECT ActivityDisplayName, Subject FROM Activities WHERE Subject = 'Sample subject'" table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Subject') etl.tocsv(table2,'activities_data.csv') table3 = [ ['ActivityDisplayName','Subject'], ['NewActivityDisplayName1','NewSubject1'], ['NewActivityDisplayName2','NewSubject2'], ['NewActivityDisplayName3','NewSubject3'] ] etl.appenddb(table3, cnxn, 'Activities')