Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →How to Visualize Act CRM Data in Python with pandas
Use pandas and other modules to analyze and visualize live Act CRM data in Python.
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, the pandas & Matplotlib modules, and the SQLAlchemy toolkit, you can build Act CRM-connected Python applications and scripts for visualizing Act CRM data. This article shows how to use the pandas, SQLAlchemy, and Matplotlib built-in functions to connect to Act CRM data, execute queries, and visualize the results.
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.
Follow the procedure below to install the required modules and start accessing Act CRM through Python objects.
Install Required Modules
Use the pip utility to install the pandas & Matplotlib modules and the SQLAlchemy toolkit:
pip install pandas pip install matplotlib pip install sqlalchemy
Be sure to import the module with the following:
import pandas import matplotlib.pyplot as plt from sqlalchemy import create_engine
Visualize Act CRM Data in Python
You can now connect with a connection string. Use the create_engine function to create an Engine for working with Act CRM data.
engine = create_engine("actcrm:///?URL=https://myActCRMserver.com&User=myUser&Password=myPassword&ActDatabase=MyDB")
Execute SQL to Act CRM
Use the read_sql function from pandas to execute any SQL statement and store the resultset in a DataFrame.
df = pandas.read_sql("SELECT ActivityDisplayName, Subject FROM Activities WHERE Subject = 'Sample subject'", engine)
Visualize Act CRM Data
With the query results stored in a DataFrame, use the plot function to build a chart to display the Act CRM data. The show method displays the chart in a new window.
df.plot(kind="bar", x="ActivityDisplayName", y="Subject") plt.show()
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 pandas import matplotlib.pyplot as plt from sqlalchemy import create_engin engine = create_engine("actcrm:///?URL=https://myActCRMserver.com&User=myUser&Password=myPassword&ActDatabase=MyDB") df = pandas.read_sql("SELECT ActivityDisplayName, Subject FROM Activities WHERE Subject = 'Sample subject'", engine) df.plot(kind="bar", x="ActivityDisplayName", y="Subject") plt.show()