Skip to main content

A package to fetch and save Power BI tables via XMLA endpoint

Project description

download_pbi_xmla

Version: 0.4
Description: A Python package to fetch and save Power BI tables via the XMLA endpoint using DAX queries. The package allows data to be saved in either Parquet or CSV format.

Table of Contents

  1. Overview
  2. System Requirements
  3. Installation
  4. Setup
  5. Usage
  6. Running the Scripts
  7. Troubleshooting
  8. Contributing
  9. License

Overview

The download_pbi_xmla package is designed to connect to a Power BI XMLA endpoint, execute DAX queries, and save the results in either Parquet or CSV formats. This tool is specifically for use in a Windows environment due to its dependency on .NET assemblies and the pythonnet library.

System Requirements

  • Operating System: Windows
  • Python Version: 3.9 to 3.12
  • Required Software: .NET Framework and Power BI Pro or Premium capacity access with XMLA endpoint enabled.
  • Authentication: The package currently only supports authentication using the Microsoft Authentication Library (MSAL) to obtain an access token, supporting Multi-Factor Authentication (MFA).

Python Version Compatibility

The download_pbi_xmla package requires Python version 3.9, 3.10, 3.11, or 3.12.

Important Note:

  • The package is not compatible with Python 3.13 or any versions above it due to a dependency on pythonnet, which only supports Python versions up to 3.12.
  • If you are using Python 3.13 or higher, please switch to a compatible Python version (3.9 to 3.12) to install and use this package.

Instructions for Checking and Changing Your Python Version

  1. Check Your Python Version:

    Run the following command in your terminal or command prompt to check your current Python version:

    python --version
    

Installation

Prerequisites

  1. Install Python
    Ensure you have Python 3.9 to 3.12 installed. You can download it from python.org.

  2. Install .NET Framework
    Install the required .NET Framework runtime from Microsoft's website.

  3. Install Poetry (optional)
    Poetry is a dependency manager for Python that simplifies package installation and management. Follow the instructions on their website to install it.

Steps to Install the Package

Option 1: Using Poetry

If you have Poetry installed, you can add the package to your environment by running:

poetry add download_pbi_xmla

Option 2: Using pip

Alternatively, you can install the package directly using pip:

pip install download_pbi_xmla

Setup

  1. Run the Setup Script
    This script copies example configuration files and prompts you to edit them.

    • Using Poetry:

      poetry run setup-files
      
    • Using pip:

      python -m download_pbi_xmla.setup_files
      
  2. Edit the Configuration Files
    After running the setup script, two configuration files (.env and config.json) will be created in your project's root directory. You need to update these files with your credentials and specific configurations.

    • .env File Example:
      Open the newly created .env file and provide your credentials and other necessary settings:
    CLIENT_ID=your-client-id
    CLIENT_SECRET=your-client-secret
    TENANT_ID=your-tenant-id
    CONFIG_FILE=config.json
    SAVE_PATH=./data
    
    • config.json File Example:
      Modify the config.json file to specify the Power BI server, database, DAX queries, and output formats:
    {
      "server": "your-server-url",
      "database": "your-database-name",
      "dax_queries": [
        {
          "query": "Add your DAX query here",
          "output_file": "Your filename here.parquet",
          "format": "parquet"
        },
        {
          "query": "Add your second DAX query here (or delete this section)",
          "output_file": "Your second filename here.csv",
          "format": "csv"
        }
      ]
    }
    

Usage

To use the package, you can execute the provided scripts to fetch data from Power BI XMLA endpoints and save it in your desired format.

Fetch and Save Data

You can run the main download script using either Poetry or pip:

  • Using Poetry:

    poetry run run-download
    
  • Using pip:

    python -m download_pbi_xmla.run_download
    

Running the Scripts

1. Fetch Tables Script

This script downloads tables and saves them using the specified configurations:

  • Using Poetry:

    poetry run fetch-tables
    
  • Using pip:

    python -m download_pbi_xmla.fetch_tables
    

2. Setup Environment Script

To set up your environment by creating necessary configuration files:

  • Using Poetry:

    poetry run setup-environment
    
  • Using pip:

    python -m download_pbi_xmla.setup_environment
    

Troubleshooting

Common Issues

  1. .NET Assemblies Not Found Ensure you have the correct version of the .NET runtime installed on your machine. The pythonnet library only works on Windows systems.

  2. Invalid Credentials Double-check that your credentials in the .env file are correct and that your Azure AD app registration has the necessary permissions to access the Power BI XMLA endpoint.

  3. Data Save Errors Ensure that the specified output paths and formats are correct. The script supports saving data as either Parquet or CSV files.

Contributing

If you'd like to contribute to this project, please fork the repository and create a pull request with your changes. Ensure that all tests pass before submitting.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

download_pbi_xmla-0.4.5.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

download_pbi_xmla-0.4.5-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file download_pbi_xmla-0.4.5.tar.gz.

File metadata

  • Download URL: download_pbi_xmla-0.4.5.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Windows/11

File hashes

Hashes for download_pbi_xmla-0.4.5.tar.gz
Algorithm Hash digest
SHA256 16a98157eea57f6bc9261a3b5a2372e1ae51f43e0a3b3bca465a13e33e9078cd
MD5 61cc729c15378f0d2f2614b1faa6864b
BLAKE2b-256 b96fa373aadc5ac89421ba55d496db8f0c9e0da9e6e67cb2b8d74c17628422b9

See more details on using hashes here.

File details

Details for the file download_pbi_xmla-0.4.5-py3-none-any.whl.

File metadata

File hashes

Hashes for download_pbi_xmla-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 412cdeeb2dcfb009ced60eec5db07d6ce5adfc800310caeff43b8577a20f595b
MD5 4a6e1fb7023080eb0a368840b6219dbf
BLAKE2b-256 6c2cafd61638c1151b2b069dad0afc65e24b69f4f478abfac90cb3aba7e12359

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page