Skip to content

CLI Reference

This page is built from the actual cqlite --help output (binary version 0.11.0, built with --features write-support). Every example on this page was run against the real test datasets (cassandra5-small-full-v3.1).

cqlite [OPTIONS] [COMMAND]

CQLite provides cqlsh-compatible access to Apache Cassandra 5.0 SSTables locally without cluster dependencies. Supports interactive REPL and one-shot query modes.

Ingestion model: provide --schema and --data-dir together to trigger schema loading and dataset discovery for query execution.


These options apply at the top level and are available regardless of which subcommand is used.

FlagShortDefaultEnv varDescription
--database <FILE>-dcqlite.dbDatabase file path
--config <FILE>-cLoad config file (TOML/YAML/JSON). Precedence: flags > env > file > defaults
--verbose-vVerbose output; repeat for more detail (-v, -vv, -vvv)
--quiet-qQuiet mode — suppress non-essential output
--format <FORMAT>tableGlobal display format: table, json, csv, parquet
--schema <PATH>CQLITE_SCHEMACQL (.cql) or JSON (.json) schema file. Required for query execution. Repeatable; order defines precedence
--data-dir <DIR>CQLITE_DATA_DIRCassandra data directory root. Combined with --schema, triggers dataset discovery. Mutually exclusive with --dataset
--dataset <DATASET>Dataset name shortcut (e.g., test_basic). Looks under CQLITE_DATASETS_ROOT/sstables/{dataset}/. Mutually exclusive with --data-dir
--execute <CQL>-eExecute a single CQL statement (one-shot mode). Alias: --query
--query <CQL>Alias for --execute
--file <CQL_FILE>-fExecute statements from a file (semicolon-terminated)
--out <OUT>CQLITE_OUTOutput format for query results. Overrides --format when specified. Values: table, json, csv, parquet
--output <FILE>-ostdoutCQLITE_OUTPUTOutput file path. Required when format is parquet
--overwriteOverwrite output file if it exists (requires --output)
--limit <N>CQLITE_LIMITCap the number of returned rows
--page-size <N>CQLITE_PAGE_SIZEReader and display pagination size
--no-colorCQLITE_NO_COLORDisable colored output
--auto-detectEnable best-effort format/version auto-detection
--cassandra-version <VER>Version hint (e.g., 5.0) for format compatibility
--writableCQLITE_WRITABLEEnable write mode (requires --write-dir)
--write-dir <DIR>CQLITE_WRITE_DIRDirectory for write operations (WAL and SSTable output)
--mutation <JSON>JSON mutation to write. Repeatable. Requires --writable
--mutations-file <FILE>JSONL file of mutations (one per line). Requires --writable
--flushForce flush memtable to SSTable after writes. Requires --writable
--enable-select-fallbackCQLITE_ENABLE_SELECT_FALLBACKExperimental: fallback to read-sstable for SELECT when ingestion unavailable. Will be removed in M3
--help-hPrint help (full with --help, summary with -h)
--version-VPrint version

When multiple format controls are present, the resolution order is:

  1. --out (or CQLITE_OUT env var) — highest priority; overrides --format
  2. --format — global display format; used when --out is not set
  3. Default: table

Verified behavior:

Terminal window
# --out json wins over --format csv
cqlite --schema schema.cql --data-dir ./sstables \
--query "SELECT id FROM test_basic.simple_table LIMIT 1" \
--out json --format csv
# Output: JSON array
# CQLITE_OUT=csv with --format json: CQLITE_OUT sets --out, which wins
CQLITE_OUT=csv cqlite --schema schema.cql --data-dir ./sstables \
--query "SELECT id FROM test_basic.simple_table LIMIT 1" \
--format json
# Output: CSV
# Explicit --out overrides CQLITE_OUT env var
CQLITE_OUT=json cqlite --schema schema.cql --data-dir ./sstables \
--query "SELECT id FROM test_basic.simple_table LIMIT 1" \
--out csv
# Output: CSV (explicit flag wins)

The CQLITE_OUT environment variable sets the default value for --out, not for --format. An explicit --out <value> on the command line overrides the env var.


Start an interactive text-based REPL with meta-commands and CQL query support.

Usage: cqlite repl

Meta-commands available inside the REPL:

CommandDescription
:config data-dir <path>Set the data directory
:config schema <path>Load a schema file
:schemaShow loaded schema
:statusShow connection status
:healthShow health metrics
:helpShow meta-command help

Status line shown in the prompt:

[OK] Mem: 24.5 MB | Data: 1.2 GB
cqlite>

Status metrics refresh every 5 seconds. The status line is disabled for piped output.

Invocation example:

Terminal window
cqlite repl \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables

For the full-screen terminal UI, use cqlite tui instead.


Start a full-screen terminal UI with panels for tables, query results, and history.

Usage: cqlite tui

Keyboard shortcuts:

KeyAction
TabNavigate between panels
F2Toggle tables panel
F3Toggle query panel
F4Toggle history panel
F5Reset layout
Ctrl+C / EscExit

Status bar shown at the bottom:

Health: OK | Mem: 24.5 MB | Data: 1.2 GB | Status: Ready | Mode: EDIT

Invocation example:

Terminal window
cqlite tui \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables

For the basic text REPL, use cqlite repl.


query — One-shot query (subcommand form)

Section titled “query — One-shot query (subcommand form)”

Friendly wrapper for one-shot query execution. The query is the positional argument.

Usage: cqlite query [OPTIONS] <QUERY>
OptionDescription
--explainShow execution plan
--timingShow query timing

Example:

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--out json \
query "SELECT id, name FROM test_basic.simple_table LIMIT 2"

Output:

[
{
"id": "0023ece7-7c4e-4705-9068-d1a59ec5fe19",
"name": "Debbie Soto"
},
{
"id": "009fb913-7173-40df-b4ea-67ed6834cfe5",
"name": "Richard Parker"
}
]

The top-level --execute / -e / --query flags (not the query subcommand) are the more common one-shot interface. See One-shot mode below.


Import data from a file into a table.

Usage: cqlite import [OPTIONS] --table <TABLE> <FILE>
OptionShortDefaultDescription
<FILE>Input file path (positional)
--table <TABLE>-trequiredTarget table name
--format <FORMAT>-fcsvInput format: csv, json, parquet
--mapping <MAPPING>-mColumn mapping (col1:field1,col2:field2)
--batch-size <N>1000Batch size for imports

Export data from a table to a file.

Usage: cqlite export [OPTIONS] --table <TABLE> <FILE>
OptionShortDefaultDescription
<FILE>Output file path (positional)
--table <TABLE>-trequiredSource table name
--format <FORMAT>-fcsvExport format: csv, json, parquet, cql
--query <QUERY>-qQuery filter (WHERE clause)
--limit <LIMIT>-lMaximum rows to export

Usage: cqlite admin <COMMAND>
SubcommandDescription
infoDisplay database information
compactCompact database files
backupBackup database
restoreRestore database from backup

Usage: cqlite schema <COMMAND>
SubcommandDescription
listList all tables
describeDescribe table structure
createCreate table from schema file
dropDrop table
loadLoad schemas from files or directories

Usage: cqlite bench <COMMAND>
SubcommandDescription
readRun read performance benchmark
writeRun write performance benchmark
mixedRun mixed workload benchmark

read-sstable — Low-level SSTable inspection

Section titled “read-sstable — Low-level SSTable inspection”

Direct SSTable inspection, bypassing the query engine and schema. Useful for debugging.

Usage: cqlite read-sstable [OPTIONS] <FILE>
OptionShortDefaultDescription
<FILE>SSTable file or directory path (positional)
--format <FORMAT>-ftableOutput format: table, json, csv, parquet
--limit <LIMIT>-lLimit number of rows
--skip <SKIP>0Skip N rows
--keys-onlyShow only partition/clustering keys
--rawShow raw binary data
--verboseEnable detailed output

Show SSTable or database file metadata, stats, and optional validation.

Usage: cqlite info [OPTIONS] [PATH]
OptionShortDefaultDescription
[PATH]Target file or database path (positional, optional)
--format <FORMAT>-ftextOutput format: text, json, csv
--detailed-dShow detailed information

maintenance — Background compaction (write-support)

Section titled “maintenance — Background compaction (write-support)”

Run incremental background compaction within a time budget. Call repeatedly from a background task for continuous compaction. Requires --writable mode.

Usage: cqlite maintenance [OPTIONS]
OptionDefaultDescription
--budget-ms <N>100Time budget in milliseconds for this maintenance step

Example:

Terminal window
cqlite \
--writable --write-dir /tmp/cqlite-data \
--schema test-data/schemas/basic-types.cql \
maintenance --budget-ms 100

Output:

Maintenance complete:
Time spent: 42ns
Rows merged: 0
Bytes written: 0 bytes
Pending compaction: false

write-stats — Write engine statistics (write-support)

Section titled “write-stats — Write engine statistics (write-support)”

Display current write engine statistics: memtable size, row count, WAL size, and generation number. Requires --writable mode.

Usage: cqlite write-stats

Example:

Terminal window
cqlite \
--writable --write-dir /tmp/cqlite-data \
--schema test-data/schemas/basic-types.cql \
write-stats

Output:

Write Engine Statistics:
Memtable size: 0 bytes
Memtable rows: 0
WAL size: 0 bytes
Generation: 1

export-sstable — Export SSTables (write-support)

Section titled “export-sstable — Export SSTables (write-support)”

Export data from the write engine as Cassandra-compatible SSTables. Requires --writable mode.

Usage: cqlite export-sstable [OPTIONS] <OUTPUT>
OptionDefaultDescription
<OUTPUT>Output directory for exported SSTables (positional)
--keyspace <KEYSPACE>exportKeyspace name for the exported SSTable
--table <TABLE>dataTable name for the exported SSTable
--compactRun compaction before export to merge multiple SSTables
--skip-validateSkip validation after export

Example:

Terminal window
cqlite \
--writable --write-dir /tmp/cqlite-data \
--schema test-data/schemas/basic-types.cql \
export-sstable /tmp/exported-sstables \
--keyspace my_keyspace --table my_table --compact

The top-level --execute flag (short: -e) and its alias --query execute a single CQL statement and exit. This is the most common usage pattern for scripting and automation.

--execute and --query are identical aliases — both are accepted by the parser and produce the same behavior.

Required flags for one-shot mode:

  • --schema <path> — schema file defining the keyspace/table structure
  • --data-dir <dir> — data directory containing the SSTable files

Verified example (run against cassandra5-small-full-v3.1):

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--query "SELECT id, name, age FROM test_basic.simple_table LIMIT 3" \
--out json

Output:

[
{
"id": "0023ece7-7c4e-4705-9068-d1a59ec5fe19",
"name": "Debbie Soto",
"age": 79
},
{
"id": "009fb913-7173-40df-b4ea-67ed6834cfe5",
"name": "Richard Parker",
"age": 58
},
{
"id": "00a74226-9bde-4259-9ba0-d74359e8013e",
"name": "Andrew Meyers",
"age": 47
}
]

The same query with -e (short form of --execute):

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
-e "SELECT id, name, age FROM test_basic.simple_table LIMIT 3" \
--out json

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--query "SELECT id, name, age FROM test_basic.simple_table LIMIT 3" \
--out csv

Output:

id,name,age
0023ece7-7c4e-4705-9068-d1a59ec5fe19,Debbie Soto,79
009fb913-7173-40df-b4ea-67ed6834cfe5,Richard Parker,58
00a74226-9bde-4259-9ba0-d74359e8013e,Andrew Meyers,47

Parquet is a binary format and cannot be written to stdout. You must provide --output <file>:

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--query "SELECT id, name, age FROM test_basic.simple_table LIMIT 100" \
--out parquet \
--output results.parquet

Output (printed to stderr):

Output written to: results.parquet

For type-fidelity caveats with Parquet output, see Output Formats: Parquet.


VariableEquivalent flagDescription
CQLITE_SCHEMA--schemaSchema file path
CQLITE_DATA_DIR--data-dirSSTable data directory
CQLITE_OUT--outQuery result output format
CQLITE_OUTPUT--outputOutput file path
CQLITE_DATASETS_ROOTRoot directory for --dataset shortcut
CQLITE_LIMIT--limitRow cap
CQLITE_PAGE_SIZE--page-sizePagination size
CQLITE_NO_COLOR--no-colorDisable color
CQLITE_WRITABLE--writableEnable write mode
CQLITE_WRITE_DIR--write-dirWrite directory
CQLITE_ENABLE_SELECT_FALLBACK--enable-select-fallbackEnable experimental SELECT fallback

CQLITE_OUT example (verified):

Terminal window
CQLITE_OUT=csv cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--query "SELECT id, name, age FROM test_basic.simple_table LIMIT 2"

Output:

id,name,age
0023ece7-7c4e-4705-9068-d1a59ec5fe19,Debbie Soto,79
009fb913-7173-40df-b4ea-67ed6834cfe5,Richard Parker,58

Write mode enables mutations, memtable management, and SSTable export. All write operations require both --writable and --write-dir.

Prerequisites:

  • Build with --features write-support (or use a release binary that includes write support)
  • Provide --write-dir pointing to a writable directory

Writing a mutation:

Terminal window
cqlite \
--writable \
--write-dir /tmp/cqlite-write \
--schema test-data/schemas/basic-types.cql \
--mutation '{"table":{"keyspace":"test_basic","table":"simple_table"},"partition_key":[{"Uuid":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}],"clustering_key":[],"operations":[{"Write":{"column":"name","value":{"Text":"Test"}}}],"timestamp_micros":1704067200000000}'

Flushing memtable to SSTable:

Terminal window
cqlite \
--writable \
--write-dir /tmp/cqlite-write \
--schema test-data/schemas/basic-types.cql \
--flush

For write statistics, compaction, and export see the write-stats, maintenance, and export-sstable subcommands above.


Log output goes to stderr only, so it never contaminates JSON/CSV stdout output. Control verbosity with:

  • (none) — INFO level
  • -vDEBUG level
  • -vv or -vvvTRACE level
  • -q / --quietERROR level only

To suppress all log output when piping query results:

Terminal window
cqlite --quiet \
--schema schema.cql \
--data-dir ./sstables \
-e "SELECT * FROM ks.tbl LIMIT 10" \
--out json

See also: Output Formats for JSON, CSV, and Parquet format details.