gpt4 book ai didi

python - 使用 Python 连接到 Power BI XMLA 端点

转载 作者:太空宇宙 更新时间:2023-11-03 10:48:27 30 4
gpt4 key购买 nike

announcement about XMLA endpoints ,我一直在尝试弄清楚如何连接到形式为 powerbi://api.powerbi.com/v1.0/myorg/[workspace name] 的 URL 作为 SSAS OLAP 多维数据集通过 Python,但我还没有得到任何工作。

我有一个高级容量的工作区,我可以使用 DAX Studio 和 SSMS 作为 explained here 连接到它,但我还没有想出如何用 Python 来做。我已经尝试安装 olap.xmla,但是当我尝试使用 Power BI URL 作为使用 powerbihttps 作为前缀的位置时,出现以下错误.

import olap.xmla.xmla as xmla
p = xmla.XMLAProvider()
c = p.connect(location="powerbi://api.powerbi.com/v1.0/myorg/[My Workspace]")
[...]
TransportError: Server returned HTTP status 404 (no content available)

我确定涉及身份验证问题,但我在这里有点不知所云。我是否需要在 ActiveDirectory 中设置一个“应用程序”并以某种方式使用 API?如何为这种连接处理身份验证?

如果有人知道演示如何专门使用 Python 连接到 Power BI XMLA 端点的任何博客文章或其他资源,那就太棒了。我的搜索失败了,但我肯定不是唯一一个尝试这样做的人。

最佳答案

@Gigga 指出连接器问题后,我开始寻找其他可与 MSOLAP 一起连接的 Python 模块,并找到了一个我可以使用的模块!

模块是adodbapi (注意 pywin32 先决条件)。

连接就这么简单:

import adodbapi

# Connection string
conn = adodbapi.connect("Provider=MSOLAP.8; \
Data Source='powerbi://api.powerbi.com/v1.0/myorg/My Workspace Name'; \
Initial Catalog='My Data Model'")

# Example query
print('The tables in your database are:')
for name in conn.get_table_names():
print(name)

它通过弹出如下窗口使用我的 Windows 凭据进行身份验证:

Sign in window

关于python - 使用 Python 连接到 Power BI XMLA 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56347765/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com