Skip to content

For Agents: Using CQLite

Terse, copy-pasteable, machine-verifiable recipes for agents that integrate with CQLite as a CLI tool, Python package, or Node.js module.

All commands on these pages were run against the real cassandra5-small-full-v3.1 test datasets. Expected outputs are trimmed but structurally accurate.

PageTaskInterface
SSTable to JSON one-linerDump a table as a JSON arrayCLI
Query from PythonOpen a database and run SELECT from PythonPython
Query from Node.jsOpen a database and run SELECT from Node.jsNode.js
Export to ParquetWrite query results to a Parquet fileCLI
Export to CSVWrite query results to a CSV fileCLI
Inspect schemaDiscover which tables and columns are availableCLI
Count rowsCount rows in a table with and without filtersCLI
Read collectionsQuery LIST, SET, and MAP columnsCLI + Python
Handle missing-schema errorsDiagnose and fix schema-not-found failuresCLI
Write a mutation and flushInsert a row and flush the memtable to SSTableCLI
Export SSTable for Cassandra importRe-export SSTables in Cassandra-compatible formatCLI

Every recipe assumes:

Terminal window
export CQLITE_DATASETS_ROOT=/path/to/test-data/datasets

Schemas are in test-data/schemas/. The write-support recipes require the CLI built with --features write-support:

Terminal window
cargo build --package cqlite-cli --features write-support
  1. Real output — every example was executed; no invented data.
  2. Exit codes documented — 0 = success; non-zero = failure.
  3. Failure modes explicit — each recipe lists the exact error text for the most common failures.
  4. Terse — code first.

Error codes used by the CLI (exit code 0 = success; all errors print to stderr) and thrown as JavaScript/Python exceptions by the bindings.

CodeCategoryDescriptionTypical cause
IOSystemI/O errors — file read/write, file not foundMissing Data.db, wrong path
SCHEMASchemaSchema or table lookup failure--schema not provided, or table name typo
QUERYQueryQuery execution or CQL syntax errorUnsupported CQL, bad column name
PARSEDataBinary format parsing or type conversion errorCorrupt SSTable, unsupported format
CONFIGConfigurationConfiguration validation errorMissing required option, bad flag combination
STORAGEStorageStorage engine errorWriteEngine misconfiguration
NOT_FOUNDNotFoundResource does not existTable has no SSTables on disk
INVALID_INPUTLogicInvalid operation or stateType mismatch in mutation, bad JSON mutation format
Exit codeMeaning
0Success
1Unhandled / internal error
2Invalid CLI arguments
3Schema or query error (SCHEMA / QUERY category)
5Parse error (PARSE category)
6File already exists (use --overwrite to force)
try {
await db.executeNative('SELECT * FROM unknown.table');
} catch (err) {
console.log(err.code); // e.g. "SCHEMA"
console.log(err.category); // e.g. "Schema"
console.log(err.isRecoverable); // false for most schema/config errors
}
import cqlite
try:
with cqlite.open('/no/such/path', schema='schema.cql') as db:
pass
except cqlite.CqliteError as e:
print(e) # human-readable message