Response formats

When using either Commands or Command-line options: you can select one of the below output formats for the response to your command.

tabular

This is the default output format.

Query results are printed as a plain text formatted table.

For example:

+--------+---------+
| name   | version |
+--------+---------+
| crate1 | 0.46.3  |
+--------+---------+
| crate2 | 0.46.3  |
+--------+---------+

json

Query results are printed as a JSON formatted object array. Keys hold the column name, and the key value holds the row value.

Tip

This format is useful for dumping results to a file that can be parsed by another tool.

Here’s an example:

[
  {
    "name": "crate1",
    "version": "0.46.3"
  },
  {
    "name": "crate2",
    "version": "0.46.3"
  }
]

json_row

Query results are printed as a JSON formatted object array, like the json format. However, each row gets its own line. For example:

{"name": "crate1", "version": "0.46.3"}
{"name": "crate2", "version": "0.46.3"}

Tip

This format is compatible with COPY FROM for re-importing data.

csv

Query results are printed as comma separated values (CSV).

Specifically:

  • The delimiter is a comma (,)

  • The quote character is an apostrophe (')

  • The escape character is a reverse solidus (\)

The first line of the CSV output contains the name of the selected columns:

name,version
crate1,0.46.3
crate2,0.46.3

object types and array types are returned as a JSON string:

name,settings[\'udc\']
crate,'{"enabled": true, "initial_delay": "10m"}'

raw

Query results are printed as the raw JSON produced by the CrateDB Python client library used by Crash.

This JSON structure provides:

  • A rows key for holding a list of rows

  • A cols key for holding a list of column titles

  • A rowcount key which holds the total number of rows returned

  • A duration key which holds the total duration of the query execution in seconds

Here’s an example:

{
  "rows": [
    [
      "crate1",
      "0.46.0"
    ],
    [
      "crate2",
      "0.46.0"
    ]
  ],
  "cols": [
    "name",
    "0.46.3"
  ],
  "rowcount": 1,
  "duration": 0.00477246
}

mixed

Query results are printed as a plain text formatted table.

However, unlike the tabular format, each row (separated by - characters) contains the column title and column value (separated by the | character).

Example:

name    | crate1
version | 0.46.3
---------------------------------------------------------------
name    | crate2
version | 0.46.3
---------------------------------------------------------------