![]() |
VOOZH | about |
dotnet tool install --global CosmoSQLClient.CosmoKv.Cli --version 6.48.26
dotnet new tool-manifestif you are setting up this repo
dotnet tool install --local CosmoSQLClient.CosmoKv.Cli --version 6.48.26
#tool dotnet:?package=CosmoSQLClient.CosmoKv.Cli&version=6.48.26
nuke :add-package CosmoSQLClient.CosmoKv.Cli --version 6.48.26
Interactive command-line shell for CosmoKv embedded databases, in the spirit of sqlite3. REPL, one-shot SQL, stdin scripts, and four output formats. Ships as a dotnet global tool.
dotnet tool install -g CosmoSQLClient.CosmoKv.Cli
After install, the binary is on PATH as cosmokv-sql.
cosmokv-sql # REPL on a transient DB
cosmokv-sql [--format=FMT] <database> # REPL on <database>
cosmokv-sql [--format=FMT] <database> [sql] # one-shot SQL
cosmokv-sql [--format=FMT] <database> - # read SQL from stdin
cosmokv-sql --help
<database> is either a bare directory path (e.g. ./mydb — sqlite3-style) or a full connection string (DataSource=./mydb;CreateIfMissing=false). The bare form is shorthand for DataSource=<path>;CreateIfMissing=true — the directory is auto-created if missing. Use the connection-string form when you want to require the database to already exist (set CreateIfMissing=false).
With no <database>, the REPL opens against a transient temp directory and removes it on exit — handy for trying things out. Use .open FILENAME from inside the REPL to switch to a persistent database (and keep your subsequent work).
Run with just a database path to drop into the interactive shell. Statements end with ; and may span multiple lines.
$ cosmokv-sql ./mydb
cosmokv-sql 1.5.0
Connected to './mydb'.
Enter ".help" for usage hints.
cosmokv-sql> CREATE TABLE Users (
...> Id BIGINT IDENTITY PRIMARY KEY,
...> Email NVARCHAR(256) NOT NULL);
0 rows affected.
cosmokv-sql> INSERT INTO Users (Email) VALUES ('a@b'), ('c@d');
2 rows affected.
cosmokv-sql> SELECT * FROM Users;
Id Email
-- -----
1 a@b
2 c@d
(2 rows)
cosmokv-sql> .quit
Pass SQL as the last positional argument. Useful for shell scripting and ad-hoc queries.
cosmokv-sql ./mydb "SELECT COUNT(*) AS n FROM Users"
Pass - instead of inline SQL to pipe a script in. The CLI splits on semicolons (outside string literals) and runs each statement in order.
cat schema.sql | cosmokv-sql ./mydb -
--format=FMT (or .format FMT inside the REPL) selects how rows are rendered. Pipe to other tools for processing.
cosmokv-sql --format=json ./mydb "SELECT Id, Email FROM Users" | jq '.[].Email'
cosmokv-sql --format=csv ./mydb "SELECT * FROM Users" > users.csv
cosmokv-sql --format=tsv ./mydb "SELECT * FROM Users" | column -t -s $'\t'
| Format | Notes |
|---|---|
table (default) |
Aligned columns with a header rule. |
csv |
RFC 4180-ish: values containing the delimiter or quotes get quoted. |
tsv |
Tab-separated; tab/newline characters in values are flattened to spaces. |
json |
Single array of objects per result set. Booleans and numerics are native JSON values. |
Dot-commands work only at the start of a fresh line (not mid-statement) and consume the whole line.
| Command | Behaviour |
|---|---|
.help |
List dot-commands. |
.open FILENAME |
Close the current connection and reopen on FILENAME (auto-created). Promotes a transient session to persistent. |
.databases |
Show the current data source (transient: … or main: …). |
.tables |
Names of every user table, alphabetically. |
.schema [TABLE] |
CREATE TABLE script for TABLE (or every table if omitted). Round-trips through the parser, so you can replay it. |
.indexes [TABLE] |
CREATE INDEX scripts for TABLE (or every table). |
.dump |
Schema + INSERT statements for the entire database — like sqlite3's .dump. Safe to replay against an empty CosmoKv. |
.backup FILENAME |
Write a COSMOBAK snapshot to FILENAME. MVCC — writes continue uninterrupted. Refuses to overwrite an existing file. |
.vacuum |
Run value-log GC to reclaim space from tombstoned/overwritten large values. Prints the number of vlog files dropped. |
.format FMT |
Switch the output format mid-session. |
.quit / .exit / Ctrl-D |
Leave the shell. |
Snapshot a database to a script:
cosmokv-sql ./prod-db ".dump" > snapshot.sql
cosmokv-sql ./fresh-db - < snapshot.sql
Pipe a query result into another tool:
cosmokv-sql --format=json ./mydb "SELECT * FROM Events WHERE created_at > '2026-05-01'" \
| jq 'group_by(.user_id) | map({user_id: .[0].user_id, n: length})'
Run a migration script:
cosmokv-sql ./mydb - < migrations/001_schema.sql
GO. A trailing ; ends the current statement.readline-style history or autocomplete; if you want those, wrap the CLI with rlwrap..dump rewrites every row as a fully-qualified INSERT. For tables with millions of rows, prefer .backup FILENAME — it writes a COSMOBAK snapshot directly without the parse/encode round-trip..backup only writes plaintext snapshots. To re-encrypt with a different key, use BackupAsync(stream, backupKey) in code.EncryptionKey=<base64> (32-byte AES-256 key, base64-encoded). Bare-path .open ./mydb opens unencrypted.CosmoSQLClient.CosmoKv — the driver this CLI uses.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.48.26 | 0 | 6/19/2026 |
| 6.48.25 | 0 | 6/19/2026 |
| 6.48.24 | 0 | 6/19/2026 |
| 6.48.23 | 0 | 6/19/2026 |
| 6.48.22 | 0 | 6/19/2026 |
| 6.48.21 | 0 | 6/19/2026 |
| 6.48.20 | 0 | 6/19/2026 |
| 6.48.19 | 0 | 6/19/2026 |
| 6.48.18 | 0 | 6/19/2026 |
| 6.48.17 | 0 | 6/19/2026 |
| 6.48.16 | 0 | 6/19/2026 |
| 6.48.14 | 0 | 6/19/2026 |
| 6.48.13 | 0 | 6/19/2026 |
| 6.48.12 | 0 | 6/19/2026 |
| 6.48.11 | 0 | 6/19/2026 |
| 6.48.10 | 0 | 6/19/2026 |
| 6.48.9 | 0 | 6/19/2026 |
| 6.48.8 | 36 | 6/18/2026 |
| 6.48.7 | 37 | 6/18/2026 |
| 6.48.6 | 38 | 6/18/2026 |