usql
$ usql Community High Riskusql provides one unified psql-inspired CLI across PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, and dozens of other databases using DSN URIs. Agents can run single queries across any supported backend using -c "..." -J (--json) or -C (--csv) without switching client binaries.
brew install xo/xo/usql One static binary with -J (--json) across 30+ SQL engines beats loading per-database MCP servers.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Uniform -J (--json), -C (--csv), -c single-query mode, -q quiet mode, and -X no-rc isolation across 30+ database drivers.
-J/--jsonand-C/--csvflags across all supported drivers-q -X -cguarantees deterministic, clean single-shot runs
Supports env-based DSNs and -X to ignore user rc files, though it lacks a client-side --readonly flag across engines.
-Xskips~/.usqlrcfor reproducible execution- Lacks universal client-side read-only mode
Single static Go binary available via Homebrew tap, go install, and GitHub releases across macOS, Linux, and Windows.
- Single binary bundles pure-Go/driver support for major DBs
Replaces psql, mysql, sqlite3, and sqlcmd with consistent \d meta-commands and -J JSON output.
- Consistent interface across Postgres, MySQL, SQLite, MSSQL, and Oracle
Well-known open-source xo/usql project under MIT license.
- Active
xoGo database tooling suite
Thorough README covering DSN syntax, supported drivers, and formatting flags, plus clear --help.
- Comprehensive driver and flag reference in README
Security, Auth & Guardrails
Reads credentials from DSN URIs (e.g., $DATABASE_URL), ~/.usqlpass, or ~/.pgpass-style files.
MIT open-source Go CLI; free.
# usql Agent Rules - Always pass `-J -q -X -c "..."` for JSON output without rc-file side effects or banners. - Store connection DSNs in env vars (`$DATABASE_URL`) rather than literal credentials in commands. - Verify target DSN (`localhost` vs production) before running write statements (`INSERT`/`UPDATE`/`DROP`).
Agent-Ready Command Recipes
Safe Read-Only Queries
usql -J -q -X "$DATABASE_URL" -c "SELECT id, email FROM users LIMIT 20;"
Connects via $DATABASE_URL, skips local rc files (-X), suppresses banners (-q), and prints JSON rows (-J).
usql -C -q -X sqlite3://app.db -c "SELECT * FROM events LIMIT 100;"
Runs a read-only SQLite query and formats output as CSV (-C).
Controlled Writes & Previews
usql -q -X "$DATABASE_URL" -f migrations/002_index.sql
Executes a reviewed SQL file against the target DSN without entering the interactive prompt.
Strengths for Agents
- + Unified
-J(--json) and-C(--csv) formatting works identically across Postgres, MySQL, SQLite, and MSSQL. - + Single static binary removes the need to install multiple vendor DB clients.
- +
-Xand-qkeep agent runs isolated from personal~/.usqlrcconfigs.
Caveats & Pitfalls
- ! Some specialized DB drivers (e.g., Oracle/ODBC) require build tags (
-tags most/all) or external client libraries. - ! No universal
--readonlyswitch; write safety relies on database user permissions.