cli¶
_get_parser¶
- msdss_data_api.cli._get_parser()[source]¶
Builds an
argparse
parser for themsdss-data
command line tool.- Returns
An
argparse
parser formsdss-data
.- Return type
Author
Richard Wen <rrwen.dev@gmail.com>
Example
from msdss_data_api.cli import _get_parser parser = _get_parser() parser.print_help()
_parse_route_settings¶
- msdss_data_api.cli._parse_route_settings(cli_route_settings)[source]¶
Parses
--set
route settings for themsdss-data
command line tool.- Parameters
cli_route_settings (list(tuple)) – List of tuples of length 3, representing the route, key setting and value setting in order.
- Returns
A dictionary that can be passed to parameter
route_settings
inmsdss_data_api.routers.get_data_router()
- Return type
Author
Richard Wen <rrwen.dev@gmail.com>
Example
from msdss_data_api.cli import _parse_route_settings from pprint import pprint cli_route_settings = [ ('create', '_restricted_tables', '["user", "data"]'), ('create', '_enable', 'True'), ('create', '_get_user', '{"superuser": True}'), ('delete', 'path', '/{dataset}'), ('delete', 'tags', '["data"]') ] route_settings = _parse_route_settings(cli_route_settings) pprint(route_settings)
_read_data_file¶
- msdss_data_api.cli._read_data_file(data_path)[source]¶
Reads a data file into a
pandas.DataFrame
object.- Parameters
data_path (str) – Path of the data file with extension. Supports
.csv
,.xlsx
/.xls
,.json
, and.xml
.- Returns
A dataframe object of the file data.
- Return type
Author
Richard Wen <rrwen.dev@gmail.com>
Example
from msdss_data_api.cli import _read_data_file data = _read_data_file('path/to/data.json')
run¶
- msdss_data_api.cli.run()[source]¶
Runs the
msdss-data
command.Author
Richard Wen <rrwen.dev@gmail.com>
Example
>>> msdss-data --help
usage: ipykernel_launcher.py [-h] [--env_file ENV_FILE] [--key_path KEY_PATH] {create,delete,get,insert,update,search,start} ... Manages data with a database optional arguments: -h, --help show this help message and exit --env_file ENV_FILE path of .env file --key_path KEY_PATH path of key file commands: {create,delete,get,insert,update,search,start} create create a dataset delete delete a dataset get query a dataset insert insert data into a dataset update update data in a dataset search search datasets start start a data api server
Create a dataset:
>>> msdss-data create <data_name> <path/to/data.json> --metadata title "Test Data"
Query dataset:
>>> msdss-data get <data_name>
Update dataset values:
>>> msdss-data update <data_name> --data <col_name> <update_value> --where <col_name> = <value>
Insert data into dataset:
>>> msdss-data insert <data_name> "[{'col_a': 1, 'col_b': 'a'}]"
Delete a dataset:
>>> msdss-data delete <data_name> --delete_all
Search datasets:
>>> msdss-data search --where "dataset = <data_name>"
Start an API server:
>>> msdss-data start