How to Visualize SAP SuccessFactors LMS Data in Python with pandas

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Use pandas and other modules to analyze and visualize live SAP SuccessFactors LMS 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 SAP SuccessFactors LMS, the pandas & Matplotlib modules, and the SQLAlchemy toolkit, you can build SAP SuccessFactors LMS-connected Python applications and scripts for visualizing SAP SuccessFactors LMS data. This article shows how to use the pandas, SQLAlchemy, and Matplotlib built-in functions to connect to SAP SuccessFactors LMS data, execute queries, and visualize the results.

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

Connecting to SAP SuccessFactors LMS Data

Connecting to SAP SuccessFactors LMS 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.

SAP SuccessFactors LMS uses OAuth authentication. Before connecting, you must configure an OAuth application tied to your SAP SuccessFactors LMS account.

To establish a connection, set the following properties:

  • User: Your SAP SuccessFactors LMS username.
  • CompanyId: Your SAP SuccessFactors company identifier.
  • Url: The SAP SuccessFactors API URL (e.g., https://api4.successfactors.com).
  • OAuthClientId: The client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.

See the Getting Started chapter of the help documentation for a guide to creating a custom OAuth app and using OAuth.

Follow the procedure below to install the required modules and start accessing SAP SuccessFactors LMS 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 SAP SuccessFactors LMS Data in Python

You can now connect with a connection string. Use the create_engine function to create an Engine for working with SAP SuccessFactors LMS data.

engine = create_engine("sapsuccessfactorslms:///?User=username&CompanyId=CompanyId&Url=https://api4.successfactors.com&InitiateOAuth=GETANDREFRESH")

Execute SQL to SAP SuccessFactors LMS

Use the read_sql function from pandas to execute any SQL statement and store the resultset in a DataFrame.

df = pandas.read_sql("SELECT ItemID, ItemTitle FROM Items WHERE Active = 'true'", engine)

Visualize SAP SuccessFactors LMS Data

With the query results stored in a DataFrame, use the plot function to build a chart to display the SAP SuccessFactors LMS data. The show method displays the chart in a new window.

df.plot(kind="bar", x="ItemID", y="ItemTitle")
plt.show()

Free Trial & More Information

Download a free, 30-day trial of the CData Python Connector for SAP SuccessFactors LMS to start building Python apps and scripts with connectivity to SAP SuccessFactors LMS 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("sapsuccessfactorslms:///?User=username&CompanyId=CompanyId&Url=https://api4.successfactors.com&InitiateOAuth=GETANDREFRESH")
df = pandas.read_sql("SELECT ItemID, ItemTitle FROM Items WHERE Active = 'true'", engine)

df.plot(kind="bar", x="ItemID", y="ItemTitle")
plt.show()

Ready to get started?

Download a free trial of the SAP SuccessFactors LMS Connector to get started:

 Download Now

Learn more:

SAP SuccessFactors LMS Icon SAP SuccessFactors LMS Python Connector

Python Connector Libraries for SAP SuccessFactors LMS Data Connectivity. Integrate SAP SuccessFactors LMS with popular Python tools like Pandas, SQLAlchemy, Dash & petl.