Keep the original CLI contract while replacing the Kotlin/JVM implementation with Go.
- Keep the command surface compatible:
ping,open,close,list,query,exec,schema,describe,begin,commit,rollback,batch- same flag names, especially
--jdbc-url - same old-style positional SQL usage for
queryandexec
- Keep the daemon/client split over a Unix domain socket at
~/.database-cli/sock. - Keep named aliases with one optional active transaction per alias.
- Keep output contracts:
querydefault: TSV with header rowquery --json: typed JSON rowsexec:{"rowsAffected":N}- mutation commands:
{"ok":true} batch: continue after per-line errors and honor per-op"json":trueon query ops
- Resulting binary must be self-contained:
- no JVM
- no JDBC jars
- no external DB client binaries
- no CGO dependency for SQLite
One Go binary dispatches between:
- client mode: normal CLI usage
- daemon mode: internal background service started by launchd
- HTTP over a Unix domain socket
- plain JSON request bodies
- plain JSON or TSV response bodies
--jdbc-url is translated to native Go drivers:
- MySQL ->
github.com/go-sql-driver/mysql - PostgreSQL ->
github.com/jackc/pgx/v5/stdlib - SQLite ->
modernc.org/sqlite
SQLite is pure Go so the binary stays self-contained.
pingstays as the daemon liveness check.query/execaccept the original positional SQL form, while--sqlis still accepted as a compatibility fallback.jdbc:sqlite::memory:is pinned to a single SQLite connection so memory databases behave the same across commands.schemaanddescribeuse dialect-specific metadata queries.read-onlyis enforced in the daemon forexec.
- build with
CGO_ENABLED=0 - install a launchd agent that runs
database-cli daemon - install a thin shell wrapper at
/opt/homebrew/bin/database-cli
- Open MySQL, PostgreSQL, and SQLite aliases using the existing flag contract.
- Run
ping, then run queries in TSV and JSON mode. - Run
begin/commit/rollbackagainst an alias. - Reject
execon a read-only alias. - Confirm batch query ops honor their JSON flag.
- Confirm the built binary runs without Java or external database client software.