Comotion Dash Data Management with Python SDK¶
[Updated: 08 February 2024]
Page Topics
Introduction¶
We have empowered users to query the Comotion Dash data lake using the Comotion SDK enabling them to:
- Use software applications to query Comotion Dash and extract data in CSV format
- Easily get set up in Python using the Python SDK
- Upload the resulting data back into the data lake
Getting started¶
Prerequisites¶
- Basic knowledge of Python: This will enable you to use the SDK effectively and understand the code examples provided.
- Familiarity with PIP for package management & installation.
Authentication and Log In¶
By following these authentication steps, you can ensure secure access to the Comotion Dash data lake:
Step | Title | Description |
---|---|---|
1. | Python Installation | Start by ensuring you have Python installed (Python 3 or later). |
2. | Comotion SDK Installion | Install the Comotion SDK with a simple command pip install comotion-sdk . This will enable the user access to interact with the data lake using the necessary libraries and tools. |
3. | Verification | Verify the installation by running comotion --help in your command prompt to ensure the SDK is correctly installed and ready to use. |
4. | Authentication | Authenticate your command line by typing in comotion authenticate .You will be prompted to provide your orgname, which is a unique identifier for your organization. After entering your orgname, a web browser will open for you to log in. |
Credentials
Our authentication method allows you to use your regular username and password instead of requiring an API key.
Remember the orgname
You can save your orgname as an environment variable COMOTION_ORGNAME to prevent the need to enter it each time you use the CLI.
Upon successful authentication, the relevant authentication keys will be automatically stored in your computer's credentials manager.
Example 1¶
This example provides insights into the available commands, their purposes, and guides you through the process of authenticating within the CLI environment.
Below is the help
output of the Command Line Interface (CLI) for interacting with the Comotion APIs
Usage: comotion [OPTIONS] COMMAND [ARGS]...
Options:
-o, --orgname TEXT unique identifier for your organisation [required]
--help Show this message and exit.
Commands:
authenticate Authenticate the user against the provided orgname
dash CLI for Comotion Dash
get-access-token Get an access token for the logged in user
get-current-user Get an id token for the logged in user
Running Queries and Extracting Data¶
This example demonstrates how to use the Comotion SDK to run queries on Comotion Dash as well as download the results in CSV format:
Example 2¶
Authentication
Authentication in your code is not necessary as the Auth class handles it automatically.
import comotion
from comotion.auth import Auth
from comotion.dash import Query
from comotion.dash import DashConfig
auth = Auth(orgname='qainitech')
dashconfig = DashConfig(auth)
query = Query(query_text='select 1', config=dashconfig)
query.wait_to_complete()
query.download_csv(output_file_path = 'somefile.csv')
API Downloads
API queries will be available for download for 3 days. More information on the SDK can be found here.
Download¶
Downloading data using the Command Line Interface (CLI) offers a streamlined and efficient method to obtain essential information from the data lake. With CLI downloads, you can quickly retrieve datasets for analysis, reporting, or sharing with key stakeholders.
Example 3¶
To download data from Comotion Dash using the CLI, run this command:
comotion dash download "Select 1" -f out.csv
See Command Line Options Or Run comotion --help
OR comotion dash --help
Before you go¶
Contribute to the community
This is an open source project, and can be contributed to by the community.
This documentation portal has been created to be your right hand of guidance on this journey. We will be evolving the content from time to time and if there is any specific information you want us to add to improve your experience, please get in touch or send us a direct email to dash@comotion.co.za.
We love hearing from you!