Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Executar consulta no SQL Server Analysis Services com IronPython


é melhor usar Microsoft.AnalysisServices.AdomdClient.dll e mdx query.and definir o resultado da consulta em conjuntos de dados em Ststem.Data montagem algo assim:
clr.AddReference ("Microsoft.AnalysisServices.AdomdClient.dll")
clr.AddReference ("System.Data")

from Microsoft.AnalysisServices.AdomdClient import AdomdConnection , AdomdDataAdapter
from System.Data import DataSet

conn = AdomdConnection("Data Source=0.0.0.0;Catalog=MyCatalog;")
conn.Open()
cmd = conn.CreateCommand()
cmd.CommandText = "your mdx query" # in your case 'select from finance'
adp = AdomdDataAdapter(cmd)
datasetParam =  DataSet()
adp.Fill(datasetParam)
conn.Close();

# datasetParam hold your result as collection a\of tables
# each tables has rows
# and each row has columns
print datasetParam.Tables[0].Rows[0][0]