Querying Commands

Introduction

To query data after importing, there is the following pattern:

mbpy <MODE> <extractor> <LOADER> [<chain1> <chain2> <chainN> โ€ฆ]

Extractors

The extractor's job is to load the initial set of data. In most cases, the extractor used is from-db which queries the SQLite database that contains imported datasets, however there are many others, as can be seen by running mbpy extract --help:

โ•ญโ”€ Extractors โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ from-csv           Define the path to csv file                                 โ”‚
โ”‚ from-excel         Define the path to csv file                                 โ”‚
โ”‚ from-excel-dl      Extract dataframes from excel downloads available in        โ”‚
โ”‚                    ManageBac.  Algorithm auto-detects columns and adds title   โ”‚
โ”‚                    column                                                      โ”‚
โ”‚ from-db-connect    use raw sql                                                 โ”‚
โ”‚ from-db            Select entities (and associated entities), fields           โ”‚
โ”‚ from-pipeline      Use pipelines as an extraction tool for more sophisticated  โ”‚
โ”‚                    data management.                                            โ”‚
โ”‚ from-api           Pass a name like students, classes, academic_info_grades    โ”‚
โ”‚ from-external-api  Call out to a list endpoint.  Default values work for OA V3 โ”‚
โ”‚                    students list endpoint. For OA, use --bearer and pass in    โ”‚
โ”‚                    the bearer via environment variable token after             โ”‚
โ”‚                    /oauth/token call.  FIXME: Add this here                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Each extractor has different paramters, which can be discovered through --help:

Loaders

The <LOADER> part of the sequence is the exporting functionality. It can output to screen, save a CSV, or even send an email.

Use the above help command to see a list of targets available.

Chains

The tail of the sequence can be "chained" together. Each of these commands accepts as input the data set from the previous command, performs some manipulation, and then outputs the resulting changed dataset.

Help for all available chain commands can be viewed using the following with the --help option.

In order to learn more about each chain command, you can use, for example with the explode chain command:

The dash - in the commands above are there as a placeholders that stands in place of a real commands, useful when using the --help feature.

In this way, it is possible to build up a small command-line data flow.

Chain Commands List

Grouping, aggregation, and transformations

Merge, join, and concatenation

Selection and Filtering

Reshaping and pivoting

Output

Debugging and Inspection

Miscellaneous

Last updated

Was this helpful?