Skip to main content

Connect to your tabular model and perform operations programmatically

Project description

PyTabular

PyPI version readthedocs pages-build-deployment

What is it?

PyTabular is a python package that allows for programmatic execution on your tabular models! This is possible thanks to Pythonnet and Microsoft's .Net APIs on Azure Analysis Services. The package should have the dll files included when you import it. See Documentation Here

Getting Started

python3 -m pip install python_tabular

In your python environment, import pytabular and call the main Tabular Class. Only parameter needed is a solid connection string.

    import pytabular
    model = pytabular.Tabular(CONNECTION_STR)

DAX Query

    model.Query(DAX_QUERY)
    # Returns a Pandas DataFrame

Refresh Tables and Partitions

    #Can be str(table name only), Table object, Partition object, or an iterable combination of the three.
    model.Refresh('Table Name')
    tables_to_refresh = ['Table Name 1', 'Table Name 2', <Table Class>, <Partition Class>]
    #Queue up the tables and partitions that you want to refresh.
    model.Refresh(tables_to_refresh)
    #NOTE if you monitor the logs you will notice a Trace is executed on the refreshes.

Built In Dax Query Helpers

    #Query Every Column
    model.Query_Every_Column() #Will return pd.DataFrame()

    #Query Every Table
    model.Query_Every_Table() #Will return pd.DataFrame()
    
    '''
    NOTE, notice the default values for the query_function argument. 
    Query_Every_Column will get COUNTROWS(VALUES(_))
    and Query_Every_Table() will get COUNTROWS(_)
    with '_' being replaced with the dax identifier to the table or column in question.
    You can replace this str with anything you want. For example output the MIN(_) or MAX(_) of each column rather than the default queries.
    '''

Backup & Revert a Table in Memory

    model.Backup_Table('TableName') #This will backup the table with surround items (columns,measures,relationships,roles,hierarchies,etc.) and will add a suffix of '_backup'
    #Make any changes to your original table and then revert or delete backup as necessary
    model.Revert_Table('TableName') #This will essentially replace your original with _backup

Run BPA from TE2

    TE2 = pytabular.TE2() #Feel free to input your TE2 File path or this will download for you.
    BPA = pytabular.BPA() #Fee free to input your own BPA file or this will download for you from: https://raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/BPARules.json
    model.Analyze_BPA(TE2.EXE_Path,BPA.Location) #This will output a list of BPA violations...

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

python_tabular-0.0.50.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_tabular-0.0.50-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file python_tabular-0.0.50.tar.gz.

File metadata

  • Download URL: python_tabular-0.0.50.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for python_tabular-0.0.50.tar.gz
Algorithm Hash digest
SHA256 da40f514b4b00cb1f3f27ce43eecbe6348971a4a07964d6a81859f8e1b03a8f0
MD5 75986b2e2b829fd0d5cd1df07ce1f177
BLAKE2b-256 fa8da9a6c6bb1016f5fa9e3aff36d100904e6bb6eb8942337a0f8bba8d509eba

See more details on using hashes here.

File details

Details for the file python_tabular-0.0.50-py3-none-any.whl.

File metadata

File hashes

Hashes for python_tabular-0.0.50-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc43d96bf71bdef2e28271d32542f2da21b56617a0160448f842e865cae2a39
MD5 deb7f83d6c9e8e233dd60c9de8de2ff3
BLAKE2b-256 1859541af8ca0467365b4761e8abb29a1d7371135fc942e9d6cd5d82a4bdb400

See more details on using hashes here.

Supported by

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