With the Python script below and the Window Scheduler, you can automate the download of csv files based on queries of the SQL API to the elasticube. This type of process comes in handy when a user needs to download information regularly to be consumed by other processes.
The script takes takes care of the authentication process and keeps the definition of the cube, query, and response file.
- jwt (pip module PyJWT)
- parse (pip module parse)
- requests (pip module requests)
- django (pip module django)
All python dependencies can be downloaded with pip. In the command line, type the following for downloading PyJWT for instance:
pip install PyJWT
The sql_to_csv.py script is attached. Note the Settings section in the script to setup server location, name of the cube, query, user email and password, REST API token, and response file.
The command that you need to set in the Scheduler is the following:
Please sign in to leave a comment.