Commonwealth CLI





The Command Line Interface (CLI) allows you to execute Commonwealth queries from your shell.


It gives you autocomplete to help you write queries, and gives you immediate feedback when something isn't right.









Set Up

Download from the link above or from the command line. Once downloaded, make the file executable and then run it.


wget -O commonwealth https://commonwealth.io/static/cli/commonwealth-macos
                      # or download using link above

chmod +x commonwealth # make it executable
./commonwealth        # execute it!

Configuration

The CLI will prompt you to enter a token to verify your identity.

Lets connect to Commonwealth. Enter the following.

Commonwealth Token
Enter a value:

Create an identity token on the Account Page, then paste it into the CLI.


Shortcuts

EnterAdd newline to current query, or execute query if it ends with ; (semicolon)
Ctrl+EnterExecute current query
TabTrigger autocomplete
Ctrl+cCancel current query
Ctrl+c+Ctrl+cExit CLI

Commands

Basic Operation: Write SQL, add semicolon to the end, press Enter.

The CLI also supports these commands:

helpShow the CLI help page
show tablesList tables that you own
show table [tablename]Show the schema for a specific table
start transactionOpen new transaction. All queries will see the same view of the data. Writes (insert, update, delete) commit at the end.
commitCommit all pending queries and close transaction
rollbackDrop all pending queries and close transaction