使用 Python 重新打开与 Power BI XMLA 端点的连接时出错

2024-04-26

我有以下 python 代码,它在函数运行时工作正常,但在第二次运行时失败。

import adodbapi

def connect_and_print(input_str):
    print("Function starting...", input_str)

    conna = adodbapi.connect("""
    Provider=MSOLAP;
    Identity Provider=https://login.microsoftonline.com/common, https://analysis.windows.net/powerbi/api, 929d0ec0-7a41-4b1e-bc7c-b754a28bddcc;
    Data Source=pbiazure://api.powerbi.com;
    Initial Catalog=[dataset_id];
    User Id=[username];
    Password=[pass];
    """)

    # Example query
    print('The tables in your database conn are:')
    for name in conna.get_table_names():
        # if name == 'TMSCHEMA_ROLES':
        print(name)
    conna.close()

    print("Function finished", input_str)

#First past connects and runs without issues
connect_and_print("first pass")

#Second pass doesnt connect (Error opening connection to...)
connect_and_print("second pass")

经过长时间等待后,第二遍失败并出现以下错误消息。

OperationalError: (com_error(-2147352567, 'Exception occurred.', (0, 'Provider', None, None, 1240640, -894947614), None), 'Error opening connection to "\nProvider=MSOLAP.8;\nIdentity Provider=https://login.microsoftonline.com/common, https://analysis.windows.net/powerbi/api, 929d0ec0-7a41-4b1e-bc7c-b754a28bddcc;\nData Source=pbiazure://api.powerbi.com;\nInitial Catalog=[dataset_id];\nUser Id=[username];\nPassword=[pass];\n"')

我需要在代码中更改哪些内容才能运行此脚本而不会出现错误?


尝试使用 Provider=MSOLAP (不带“.8”) 这对我有用...

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Python 重新打开与 Power BI XMLA 端点的连接时出错 的相关文章

随机推荐