Strategy One

Use a Python Query to Retrieve Data From Web Services

Establish live connections to web services using Python queries, replacing the need for XQuery.

Prerequisites

  • The Python Query Report is dependent on the Python Service functionality.

    • Python Service is available for use in containerized environments as well as uncontainerized Managed Cloud Enterprise (MCE) deployments.
    • To enable this feature, contact Strategy Support for assistance.
  • Required Privileges:

    • Use Scripts Python
    • Certify Python Scripts
    • Use Freeform SQL

Create Python Query Data Source

  1. Open the Workstation page.

  2. In the Navigation pane on the left, click Data Sources.

  3. Click Add New Data Source on the right.

  4. In the Data Source Types window, select Python Query.

  5. Next to Name, enter a title for the data source.
  6. Optionally, provide a Description for the data source.
  7. From the Python Runtime drop-down list, select a Python Runtime.

  8. Configure the database connection, and then click Save.

Create a Python Query Report

  1. Open the Workstation window.
  2. In the Navigation pane, click Data.
  3. In the top right corner, click Create New Dataset.
  4. In the Create New window, if you are connected to multiple projects, select the project from the drop-down list on the top.
  5. Click Python Query Cube. The New Python Query Cube pane displays.
  6. From the Data Source drop-down list, select the Python Query data source.
  7. In the Python Editor, enter your Python code, and then click Run to display the data in the Table Preview tab.

    The Python code must contain a function called get_data() with a data frame object returned, as shown in the example below.

  8. If needed, add a prompt by clicking Insert Prompt on the toolbar.
  9. In the Mapping pane, map the columns to objects in the data source.

  10. On the toolbar, click the Save and Open Report icon .
  11. Add attribute and metrics to the Editor panel and run the report.

  12. Save and close the report.

Create a Python Query Cube

  1. Open the Workstation window.
  2. In the Navigation pane, click Data.
  3. In the top right corner, click Create New Dataset.
  4. In the Create New window, if you are connected to multiple projects, select the project from the drop-down list on the top.
  5. Click Python Query Cube. The New Python Query Cube pane displays.
  6. From the Data Source drop-down list, select the Python Query data source.
  7. In the Python Editor, enter your Python code, and then click Run to display the data in the Table Preview tab.

    The Python code must contain a function called get_data() with a data frame object returned, as shown in the example below.

  8. In the Mapping pane, map the columns to objects in the data source.

  9. On the toolbar, click the Save and Open Cube icon .
  10. Save and publish the cube.

Related Topics

Create and Edit Python Runtimes

Using XQuery to retrieve data from a web service

Prompts in Freeform SQL reports