Using the Quintessence.py Package
This article explains how to call Quintessence functions from Python using the Quintessence.py package.
We will demonstrate this using a Report call. In Excel, the following formula executes the report:
=Qx.Report("Return Identity Matrix", "True", "3")This returns a 3×3 identity matrix. Below, we show the Python equivalent.
1. Download and Import the Quintessence.py Package
First, download the Quintessence.py package from the Third‑Party screen of the Quintessence Studio. Once downloaded, import it into your Python environment (assuming the file is in your current working directory):
from Quintessence import Quintessence
Qx = Quintessence(
engines_address='AlphaMachine',
engines_port='port_for_http_calls',
api_key='example_api_key'
)Note:
api_keyandengines_portare provided by Quintessence.engines_addressrefers to the hostname of the Quintessence server you are connecting to.
This example uses HTTP, but HTTPS is also supported (note that some modifications to the Quintessence.py file are required to enable HTTPS). After initialization, all Quintessence functions can be called using the Qx. prefix.
2. Calling a Report from Python
To call the same report you executed in Excel, use:
Qx.report('Return Identity Matrix', 'True', '3')Note:
Python queries, along with queries for all other supported third‑party integrations, can be automatically generated from the Third‑Party screen in Quintessence Studio. This helps ensure the correct parameters and syntax for your environment.
3. Full Example
from Quintessence import Quintessence
Qx = Quintessence(
engines_address='AlphaMachine',
engines_port='port_for_http_calls',
api_key='example_api_key'
)
create_identity_matrix = Qx.report('Return Identity Matrix', 'True', '3')
print(create_identity_matrix)
Output:
[[1, 0, 0],[0, 1, 0],[0, 0, 1]]
