17
votes

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
1
It is an OLEDB driver not ODBC. Maybe try pypi.org/project/pyoledb ?GregGalloway
It's seems like this library not exist anymore: Could not find a version that satisfies the requirement pyoledbItzik Friedland
Was there any resolution ? Were you able to connect python with azure AS.sanjay
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.Itzik Friedland
@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.Jai Prakash

1 Answers

3
votes

From this answer: https://stackoverflow.com/a/33727190/1198321

It seems that the adodbapi library supports connecting to OLEDB.