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 ID=myuser@mail.com;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 ID=myuser@mail.com;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
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Itzik Friedland
  • 247
  • 2
  • 7
  • 2
    It is an OLEDB driver not ODBC. Maybe try https://pypi.org/project/pyoledb/ ? – GregGalloway Jun 10 '18 at 18:36
  • It's seems like this library not exist anymore: `Could not find a version that satisfies the requirement pyoledb` – Itzik Friedland Jun 11 '18 at 08:24
  • 2
    Was there any resolution ? Were you able to connect python with azure AS. – sanjay Nov 30 '18 at 05:54
  • 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 Dec 05 '18 at 13:16
  • 1
    @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 Nov 09 '20 at 06:33
  • @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 that – Itzik Friedland Dec 24 '20 at 11:08

1 Answers1

3

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

It seems that the adodbapi library supports connecting to OLEDB.

lxop
  • 7,596
  • 3
  • 27
  • 42