title: Use Python to Query SQL Server Analysis Services (SSAS) cube Data
body: <p>There is a SQL analysis service resource in my organization, we can use excel or powerbi to connect to the cube use a server name (tooldata.amr.xxx.com) and get the data.</p>
  
  <p>What i want is use python or excel to automate the data query and output to a csv file for downstream application use (reporting/chart etc.)</p>
  
  <p><strong>I've tried below but failed:</strong></p>
  
  <p>1.<a href="https://stackoverflow.com/a/24731854/10562099">Microsoft.AnalysisServices.AdomdClient</a></p>
  
  <p>FileNotFoundException                     Traceback (most recent call last)
   in </p>
  
  <blockquote>
  <pre><code>2. clr.AddReference ("Microsoft.AnalysisServices.AdomdClient.dll")
  </code></pre>
  </blockquote>
  
  <p>FileNotFoundException: <strong>Unable to find assembly 'Microsoft.AnalysisServices.AdomdClient.dll'.
     at Python.Runtime.CLRModule.AddReference(String name)</strong></p>
  
  <p>look like lack of some env. not sure how to proceed. any suggestion ?</p>
  
  <p>2.<a href="http://blog.soft-prestidigitation.com/ssas-via-python.html" rel="nofollow noreferrer">use olap.xmla </a></p>
  
  <pre><code>import olap.xmla.xmla as xmla 
  provider = olap.xmla.xmla.XMLAProvider()
  connect = provider.connect(location='http://tooldata.amr.xxx.com/OLAP/msmdpump.dll',username='user',password='pwd')
  source = connect.getOLAPSource()
  print (source.getCatalog("TestCube"))
  </code></pre>
  
  <blockquote>
    <p>ConnectionError: HTTPConnectionPool(host='tooldata.amr.xxx.com', port=80): Max retries exceeded with url: /OLAP/msmdpump.dll (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))</p>
  </blockquote>
  
  <p>Looks like need some configuration from server side, but it's out of my control, drop this option.</p>
  
  <p>3.since i can use excel to get the SSAS data, is that possible use python to call excel and refresh the data, then parse out the data from excel? have any one try that? </p>
  
  <p>thanks .</p>