且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Python查询SQL Server Analysis Services(SSAS)多维数据集数据

更新时间:2022-04-22 16:49:18

最后,基于

clr是 pythonnet ,您可以通过以下方式安装软件包: pythonnet Github pythonnet pypi

clr is pythonnet, you can install the package via: pythonnet Github or pythonnet pypi

对于 Microsoft.AnalysisServices.AdomdClient.dll ,可能您没有.您可以通过安装 SQL_AS_ADOMD.msi 来获取DLL.

And for the Microsoft.AnalysisServices.AdomdClient.dll probably you don't have it. you can get the DLL by install SQL_AS_ADOMD.msi .

最后,旨在解析来自Cube DataSet的结构化数据集.我使用下面的代码(字段取决于您的DAX查询输出).

Lastly , aim to parse a structured dataset from the Cube DataSet. i use below code (field depends on your DAX query output).

with open ('xx_Pivot.csv','w') as file:
#my MDX only return 7 field as below headers.
header = 'WW,Shift,ShiftID,Factory,Entity,Cell,Data\n'
file.writelines(header)
#iteration the Dataset and get out a structure 2D data table and save to a file.
for row_n in range(len(list(datasetParam.Tables[0].Rows))):
    row = ''
    for column_n in range(7):
        data = datasetParam.Tables[0].Rows[row_n][column_n]
        row = row+str(data)+',' 
    row = row+'\n'
    file.writelines(row)

这篇关于使用Python查询SQL Server Analysis Services(SSAS)多维数据集数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!