may-day / olap

Python package to access OLAP data sources.
63 stars 47 forks source link

Is it possible to connect to PowerBI? #27

Open slarionoff opened 1 year ago

slarionoff commented 1 year ago

I'm trying to access a PBI data using XMLS endpoint, my code looks like this:

    url = f"powerbi://api.powerbi.com/v1.0/myorg/{workspace_name}"
    print(url)

    p = xmla.XMLAProvider()
    c = p.connect(location=url)       # <-- code fails here

The output is given below:

powerbi://api.powerbi.com/v1.0/myorg/<My workspace name>
Traceback (most recent call last):
  File "<My project path>\test XMLA connectivity.py", line 130, in <module>
    get_pbi_data_with_dax_XMLA(workspace_name, initial_catalog, sp_powerbi_login, sp_powerbi_pass, dax)
  File "<My project path>\test XMLA connectivity.py", line 97, in get_pbi_data_with_dax_XMLA
    c = p.connect(location=url)
  File "<My project venv>\Lib\site-packages\olap\xmla\olap\xmla\xmla.py", line 26, in connect
    return XMLASource(url, location, sslverify, **kwargs)
  File "<My project venv>\Lib\site-packages\olap\xmla\olap\xmla\xmla.py", line 143, in __init__
    XMLAConnection.__init__(self, urlwsdl, location, sslverify, **kwargs)
  File "<My project venv>\Lib\site-packages\olap\xmla\olap\xmla\connection.py", line 124, in __init__
    self.client = Client(url, 
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\client.py", line 76, in __init__
    self.wsdl = Document(wsdl, self.transport, settings=self.settings)
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\wsdl\wsdl.py", line 92, in __init__
    self.load(location)
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\wsdl\wsdl.py", line 95, in load
    document = self._get_xml_document(location)
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\wsdl\wsdl.py", line 155, in _get_xml_document
    return load_external(
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\loader.py", line 89, in load_external
    content = transport.load(url)
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\transports.py", line 123, in load
    content = self._load_remote_data(url)
  File "<My project venv>\lib\site-packages\zeep-4.2.1-py3.10.egg\zeep\transports.py", line 135, in _load_remote_data
    response = self.session.get(url, timeout=self.load_timeout)
  File "<My project venv>\lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "<My project venv>\lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "<My project venv>\lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "<My project venv>\lib\site-packages\requests_file-1.5.1-py3.10.egg\requests_file.py", line 34, in send
    raise ValueError("file: URLs with hostname components are not permitted")
ValueError: file: URLs with hostname components are not permitted

Installation was done the way it is shown in a Readme in Cygwin, a step pipenv install -dev was omitted as it said:

pipenv install -dev
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRT
UALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "<My project venv>\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "<My project venv>\lib\site-packages\pipenv\cli\options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "<My project venv>\lib\site-packages\pipenv\vendor\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "<My project venv>\lib\site-packages\pipenv\cli\command.py", line 235, in install
    do_install(
  File "<My project venv>\lib\site-packages\pipenv\routines\install.py", line 69, in do_install
    ensure_project(
  File "<My project venv>\lib\site-packages\pipenv\utils\project.py", line 32, in ensure_project
    ensure_virtualenv(
  File "<My project venv>\lib\site-packages\pipenv\utils\virtualenv.py", line 148, in ensure_virtualenv
    python = ensure_python(project, python=python)
  File "<My project venv>\lib\site-packages\pipenv\utils\virtualenv.py", line 242, in ensure_python
    path_to_python = find_a_system_python(python)
  File "<My project venv>\lib\site-packages\pipenv\utils\virtualenv.py", line 353, in find_a_system_python
    finder = Finder(system=False, global_search=True)
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 24, in __init__
    self.system_path = self.create_system_path()
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 38, in create_system_path
    return SystemPath.create(
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 541, in create
    instance._run_setup()
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 200, in _run_setup
    venv = ensure_path(venv)
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\utils.py", line 237, in ensure_path
    path = possibly_convert_to_windows_style_path(path)
  File "<My project venv>\lib\site-packages\pipenv\vendor\pythonfinder\environment.py", line 26, in possibly_convert_to_windows_style_path
    drive, tail = re.match(r"^/([a-zA-Z])/(.*)", path).groups()
AttributeError: 'NoneType' object has no attribute 'groups'
(venv)

Am I right that this XMLA reader requires some DLLs that are not of open-source type?

Thank you!