VOOZH about

URL: https://www.nuget.org/packages/CosmoSQLClient.CosmoKv.Cli/

⇱ NuGet Gallery | CosmoSQLClient.CosmoKv.Cli 6.48.26




CosmoSQLClient.CosmoKv.Cli 6.48.26

dotnet tool install --global CosmoSQLClient.CosmoKv.Cli --version 6.48.26
 
 
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
 
if you are setting up this repo
dotnet tool install --local CosmoSQLClient.CosmoKv.Cli --version 6.48.26
 
 
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=CosmoSQLClient.CosmoKv.Cli&version=6.48.26
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package CosmoSQLClient.CosmoKv.Cli --version 6.48.26
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

cosmokv-sql — CLI shell for CosmoKv databases

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.

Install

dotnet tool install -g CosmoSQLClient.CosmoKv.Cli

After install, the binary is on PATH as cosmokv-sql.

Usage

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. ./mydbsqlite3-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).

REPL

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

One-shot

Pass SQL as the last positional argument. Useful for shell scripting and ad-hoc queries.

cosmokv-sql ./mydb "SELECT COUNT(*) AS n FROM Users"

Stdin

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 -

Output formats

--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.

REPL dot-commands

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.

Examples

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

Limitations

  • Statement splitting is lexical only — it understands single-quoted strings but not block comments or T-SQL GO. A trailing ; ends the current statement.
  • No 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.
  • Opening an encrypted store from the shell requires a connection string with EncryptionKey=<base64> (32-byte AES-256 key, base64-encoded). Bare-path .open ./mydb opens unencrypted.

Related

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed