Search code examples
pythonssas

Python connecting SSAS with pyadomd


I've connected to my SSAS Cube using Python, however I'm having some problems with executing the MDX query. Here is the code that I've used:

from sys import path

path.append('\\Program Files\\Microsoft.NET\\ADOMD.NET\\140')

from pyadomd import Pyadomd


conn_str = 'connection_str'
query = """mdx_query"""

with Pyadomd(conn_str) as conn:
    with conn.cursor().execute(query) as cur:
        print(cur.fetchall())

I've checked connection using print(conn.state) and everything is ok.

The error that I'm getting:

Traceback (most recent call last):
  File "C:/Users/kkrukows/PycharmProjects/test/main.py", line 22, in <module>
    with conn.cursor().execute(query) as cur:
  File "C:\Users\kkrukows\Anaconda3\envs\test\lib\site-packages\pyadomd\pyadomd.py", line 71, in execute
    adomd_type_map[self._reader.GetFieldType(i).ToString()].type_name
KeyError: 'System.Object'

Anyone able to help?


Solution

  • Please upgrade the package to version 0.0.6 and try again.

    You can do that using pip:

    pip install pyadomd --upgrade