Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Applies to:Image RemovedKyvos Enterprise  Image RemovedKyvos Cloud (Managed Services on AWS)  Image RemovedKyvos Azure Marketplace

...

Applies to: (tick) Kyvos Enterprise  (tick) Kyvos Cloud (SaaS on AWS) (tick) Kyvos AWS Marketplace

(tick) Kyvos Azure Marketplace   (tick) Kyvos GCP Marketplace (tick) Kyvos Single Node Installation (Kyvos SNI)

...

...

This section explains how you can connect Python to Kyvos semantic models using the MDX connection.

Prerequisites

To connect Kyvos using Python, you must have the following.

  1. Python (3 and above) must be hosted either on an analyst’s machine or on Hadoop Cluster (Cloud/On-Premises).

Steps to connect

  1. Open the Command prompt (CMD).

  2. Run the following command to create a test environment.
    python3

...

  1. -m

...

  1. venv

...

  1. python_testenv

  2. Run the following command to enter the test environment.

    cd

...

  1. python_testenv

  2. On Windows/Mac computer, run the following command to activate the test environment.

    Scripts\activate.bat

  3. On Linux, run the following command to activate the test environment.

    source

...

  1. bin/activate

  2. Go to URL: https://github.com/may-day/olap

  3. Download the olap-master.zip folder as shown in the following figure.

...

  1. Image Added
  2. Extract files from the downloaded zip folder, copy the unzipped folder (named – olap-master), and paste it in the test environment folder location (created as mentioned in Step 4)

  3. Switch to CMD and run the following commands:

    Code Block
    languagepy

...

...

  1. cd olap-master
    cd olap-master
    cd xmla
  2. Install the following libraries:

    Code Block
    languagepy

...

...

  1. pip install zope
    pip install olap
    pip install xmla
    pip install lxml
    pip install zeep==3.4.0
  2. Copy the Python Code, paste it on the notepad file, edit the code by providing your Kyvos server URL in Kyvos Server IP, Kyvos User ID, and Password (within the double quotes) on Line#3 and #4 and save the notepad file with extension .py in the C:\Users\python_testenv\olap-master\olap-master\xmla folder.

    Code Block
    languagepy

...

...

  1. import olap.xmla.xmla as xmla
    p = xmla.XMLAProvider()
    c = p.connect(location="http://<Kyvos Server IP>:8081/kyvos/xmlaKyvos", auth=("<Enter Kyvos User Name>", "<Enter Kyvos Password>"))
    sba = """
    SELECT NON EMPTY Hierarchize(AddCalculatedMembers({DrilldownLevel({[Vendor].[H_Vendor].[Hierarchy.ALL].[0]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS  FROM [NYC] WHERE ([Measures].[fare_amount]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
    """
    tweetRes = c.Execute(sba, Catalog="NYC")
    i= tweetRes.getSlice()
    l= tweetRes.getSlice(Axis0=0)
    m= tweetRes.getSlice(Axis0=0,SlicerAxis=0)
    print(m)

...

  1. Switch to CMD and execute the script by running the following command.

    Code Block
    languagepy

...

...

  1. py <filename.py>
  2. After the script runs, it gives an output of the MDX as shown in the following figure.

...

Read more

Child pages (Children Display)

...