Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Azure analysis services from python

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
like image 485
Itzik Friedland Avatar asked Jun 10 '18 13:06

Itzik Friedland


1 Answers

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

It seems that the adodbapi library supports connecting to OLEDB.

like image 124
lxop Avatar answered Nov 08 '22 18:11

lxop