通过xmla访问olap数据源
xmla的Python项目详细描述
olap.xmla
此包用于访问xmla数据源-请参阅 http://en.wikipedia.org/wiki/XML_for_Analysis
建筑
在此目录中,运行:
python setup.py build
测试
对mondrian、ssas、iccube xmla提供者进行测试。这个 testsdiscover模块使用不同的xmla提供程序测试行为 testsexecute执行时的discover命令 命令。请注意,如果您希望 测试你自己,因为它们包含了细节(即 服务和数据源的名称)。
样品
下面是一个如何使用它的示例:
import olap.xmla.xmla as xmla p = xmla.XMLAProvider() # mondrian c = p.connect(location="http://localhost:8080/mondrian/xmla") # to analysis services (if iis proxies requests at /olap/msmdpump.dll) # you will need a valid kerberos principal of course # c = p.connect(location="https://my-as-server/olap/msmdpump.dll", # sslverify="/path/to/my/as-servers-ca-cert.pem") # to icCube # c = p.connect(location="http://localhost:8282/icCube/xmla", username="demo", # password="demo") # getting info about provided data print c.getDatasources() print c.getMDSchemaCubes() # for ssas a catalog is needed, so the call would be like # get a catalogname from a call to c.getDBSchemaCatalogs() # c.getMDSchemaCubes(properties={"Catalog":"a catalogname"}) # execute a MDX (working against the foodmart sample catalog of mondrian) cmd= """select {[Measures].ALLMEMBERS} * {[Time].[1997].[Q2].children} on columns, [Gender].[Gender].ALLMEMBERS on rows from [Sales] """ res = c.Execute(cmd, Catalog="FoodMart") #return only the Value property from the cells res.getSlice(properties="Value") # or two props res.getSlice(properties=["Value", "FmtValue"]) # to return some subcube from the result you can # return all res.getSlice() # carve out the 4th column res.getSlice(Axis0=3) # same as above, SlicerAxis is ignored res.getSlice(Axis0=3, SlicerAxis=0) # return the data sliced at the 2nd and 3rd row res.getSlice(Axis1=[1,2]) # return the data sliced at the 2nd and 3rd row and at the 4th column res.getSlice(Axis0=3, Axis1=[1,2])
使用程序界面:
import olap.xmla.xmla as xmla p = xmla.XMLAProvider() c = p.connect(location="http://localhost:8080/mondrian/xmla") s = p.getOLAPSource() # import olap.interfaces as oi # oi.IOLAPSource.providedBy(s) == True s.getCatalogs() s.getCatalog("FoodMart").getCubes() s.getCatalog("FoodMart").getCube("HR").getDimensions() s.getCatalog("FoodMart").getCube("HR").getDimension("[Department]").\ getMembers() s.getCatalog("FoodMart").getCube("HR").getDimension("[Department]").\ getMember("[Department].[14]") cmd= """select {[Measures].ALLMEMBERS} * {[Time].[1997].[Q2].children} on columns, [Gender].[Gender].ALLMEMBERS on rows from [Sales] """ res=s.getCatalog("FoodMart").query(cmd) res.getSlice()
注
包含的vs.wsdl源于以下包: http://www.microsoft.com/en-us/download/confirmation.aspx?id=9388和 随后被修改(soap头中的参数)为 使用suds package.olap.xmla
更改
0.7.2
- 现在依赖于请求1.2.3
- 修复了kerberos auth中的竞争条件
0.7.1
- kerberos身份验证已发送两次
0.7
- 现在可以处理请求0.14和1。-一系列请求
- 选择单元格属性失败
0.6
- 依赖kerberos和s4u2p现在是可选的
- 通过pywin32通过sspi为windows上的kerberos添加了可选的kerberos sspi包
0.5
- as_user和spn在kerberos身份验证中不再被忽略
- 从olap.interfaces实现了过程接口
- 当没有SLILIXAX信息返回< /LI>时的固定问题
- getslice的参数property现在拼写为properties
0.4
- 关键字kerberos已不存在。会自动检测到kerberos身份验证需要
- BeginSession和EndSession提供xmla会话支持
- 使用iccube xmla provider的更改
0.3
- 已更改xmlprovider中的关键字doKerberos。请连接到kerberos
- 向xmlprovider.connect添加了sslverify关键字,默认为True。 这将被传递给requests get方法,因此您可以将其指向证书捆绑包文件。
0.2
- 删除了对setup.py中特定版本的依赖关系