MS Analysis Services OLAP API for Python [closed] MS Analysis Services OLAP API for Python [closed] database database

MS Analysis Services OLAP API for Python [closed]


This can be done quite easily using pythonnet:

http://pythonnet.github.io/

You load the Microsoft.AnalysisServices.dll that is provided with SQL Server 2005 and 2008 or get the redistributable package here:

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b33d2c78-1059-4ce2-b80d-2343c099bcb4

search for SQLSERVER2008_ASAMO10.msi

Then you can load it up and use it. Here is an example that simply processes cubes:

import CLRfrom CLR.System.Reflection import AssemblyAssembly.LoadWithPartialName("AnalysisServices.DLL")from CLR.Microsoft.AnalysisServices import Serverfrom CLR.Microsoft.AnalysisServices import ProcessTypeserverName = 'localhost\sql2005'dbName = 'MyDatabase'# Connect to serveramoServer = Server()amoServer.Connect(serverName)# Connect to database  amoDb = amoServer.Databases[dbName]    amoDb.Process(ProcessType.ProcessFull)


I am completely ignorant about Python, but if it can call DLLs then it ought to be able to use Microsoft's ADOMD object. This is the best option I can think of.

You could look at Office Web Components (OWC) as that has a OLAP control than can be embedded on a web page. I think you can pass MDX to it, but perhaps you want Python to see the results too, which I don't think it allows.

Otherwise perhaps you can build your own 'proxy' in another language. This program/webpage could accept MDX in, and return you XML showing the results. Python could then consume this XML.


You can easily connect and access OLAP cubes with the help of python package xmla. xmla plays a vital role in communicating with OLAP and performs all functions with the cubes.

Install xmla package either by

python -m pip install xmla --user

or

python -m venv xmlaenv# python -m venv --without-pip xmlenv - use if the above commands throws errorcd xmlaenvsource bin/activategit clone https://github.com/may-day/olapcd olap/xmla# optional if you have it alreadypip install pipenvpipenv install -devpython setup.py develop

After installation, Connect to OLAP XMLA Cubes using location, username and password parameters.

import olap.xmla.xmla as xmlaprovider = xmla.XMLAProvider()connect = provider.connect(location='http://localhost/OLAP/msmdpump.dll', username = 'test', password = 'test')source = connect.getOLAPSource()