Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhangyuan/mc-cli

A CLI for querying and executing SQL statements against MaxCompute (ODPS).
https://github.com/zhangyuan/mc-cli

Last synced: about 1 month ago
JSON representation

A CLI for querying and executing SQL statements against MaxCompute (ODPS).

Awesome Lists containing this project

README

        

# mc-cli

## Usage

### Setup the credentials

Create the `.env` file with the sample content as below:

```env
DSN=http://ACCESS_KEY_ID:[email protected]/api?project=project_name
```

If multiple SQL statements will be executed, `odps.sql.submit.mode=script` must be set. So the DSN would be like:

```env
DSN=http://ACCESS_KEY_ID:[email protected]/api?project=project_name&odps.sql.submit.mode=script
```

### Query the data via single SQL statement

```bash
./mc-cli query -s "SELECT 1"
```

or use the SQL from file:

```bash
./mc-cli query -f sample.sql
```

Variables in the same style as Dataworks ODPS node are supported via `--dataworks-vars|-v` or `dataworks-vars-file|-d`. E.g.

```bash
./mc-cli query -f sample.sql -d sample.yaml
```

### Execute SQL statement(s)

```bash
./mc-cli exec -f sample.sql
```

or

```bash
./mc-cli exec -f sample.sql -d sample.yaml
```