Connect to Azure analysis services from python
Asked Answered
R

1

17

I have Azure analysis service instance, with a tabular model, I need to query the data by DAX or MDX from a python script.

I got a connection string from Azure that look's like this:

Provider=MSOLAP;Data Source=asazure://eastus.asazure.windows.net/mymodel;Initial Catalog=mycatalog;User [email protected];Password=mypass;Persist Security Info=True;Impersonation Level=Impersonate

I tried to connect to that connection string with pyodbc:

import pyodbc

connection_str = "Provider=MSOLAP;Data Source=asazure://eastus.asazure.windows.net/mymodel;" \
                 "Initial Catalog=mycatalog;User [email protected];Password=mypass;" \
                 "Persist Security Info=True;Impersonation Level=Impersonate"

my_connection = pyodbc.connect(connection_str)

I got this error:

Traceback (most recent call last):
  File "C:/workspace/test.py", line 7, in <module>
    my_connection = pyodbc.connect(connection_str)
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

Process finished with exit code 1
Ramses answered 10/6, 2018 at 13:34 Comment(6)
It is an OLEDB driver not ODBC. Maybe try pypi.org/project/pyoledb ?Payment
It's seems like this library not exist anymore: Could not find a version that satisfies the requirement pyoledbRamses
Was there any resolution ? Were you able to connect python with azure AS.Beatific
Unfortunately I didn't found any library or interface, we created a rest interface with C# that pass the DAX requests to the Analysis Services and returns the results as JSON.Ramses
@ItzikFriedland i have a similar requirement. Even after two years i am unable to find a way in python to connect Azure Analysis services. Can you please share the abstract of your C# code.Adscititious
@JaiPrakash, unfortunately, I didn't write the C# code, but the idea was to expose GET request that received DAX statement and return the relevant result based on thatRamses
S
3

From this answer: https://mcmap.net/q/165864/-connecting-to-microsoft-sql-server-using-python

It seems that the adodbapi library supports connecting to OLEDB.

Shortbread answered 6/12, 2018 at 12:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.