pbi_helper
pbi_helper.py
was reverse engineered from DaxStudio PowerBiHelper.cs
.
So all credit and genius should go to DaxStudio.
I just wanted it in python...
The main function is find_local_pbi_instances()
.
It will find any open PBIX files on your computer and spit out a connection string for you.
get_msmdsrv()
Runs powershel command to retrieve the ProcessId.
Uses Get-CimInstance
where Name == 'msmdsrv.exe'
.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
returns ProcessId(s) in list. Formatted to account for multiple PBIX files open at the same time. |
Source code in pytabular/pbi_helper.py
get_port_number(msmdsrv)
Gets the local port number of given msmdsrv ProcessId. Via PowerShell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msmdsrv |
str
|
A ProcessId returned from |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
|
Source code in pytabular/pbi_helper.py
get_parent_id(msmdsrv)
Gets ParentProcessId via PowerShell from the msmdsrv ProcessId.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msmdsrv |
str
|
A ProcessId returned from |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Returns ParentProcessId in |
Source code in pytabular/pbi_helper.py
get_parent_title(parent_id)
Takes the ParentProcessId and gets the name of the PBIX file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_id |
str
|
Takes ParentProcessId which can be retrieved from |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Returns str of title of PBIX file. |
Source code in pytabular/pbi_helper.py
create_connection_str(port_number)
This takes the port number and adds to connection string.
This is pretty bland right now, may improve later.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port_number |
str
|
port number retrieved from |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
port number as string. |
Source code in pytabular/pbi_helper.py
find_local_pbi_instances()
The real genius is from Dax Studio.
I just wanted it in python not C#, so reverse engineered what DaxStudio did. It will run some powershell scripts to pull the appropriate info. Then will spit out a list with tuples inside. You can use the connection string to connect to your model with pytabular. Dax Studio.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
EX |