Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

usql

$ usql Community High Risk
xo (OSS) · Database & Data · MIT · macos / linux / windows

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

FCRS-1.0 Score
86 /100
Good
Medium Confidence
Zero-Friction Install
brew install xo/xo/usql
CLI vs MCP Decision CLI Preferred vs MCP

One static binary with -J (--json) across 30+ SQL engines beats loading per-database MCP servers.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 22 / 25

Uniform -J (--json), -C (--csv), -c single-query mode, -q quiet mode, and -X no-rc isolation across 30+ database drivers.

  • -J / --json and -C / --csv flags across all supported drivers
  • -q -X -c guarantees deterministic, clean single-shot runs
Trust & Safety 20 / 25

Supports env-based DSNs and -X to ignore user rc files, though it lacks a client-side --readonly flag across engines.

  • -X skips ~/.usqlrc for reproducible execution
  • Lacks universal client-side read-only mode
Setup & Portability 14 / 15

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
Utility & Efficiency 14 / 15

Replaces psql, mysql, sqlite3, and sqlcmd with consistent \d meta-commands and -J JSON output.

  • Consistent interface across Postgres, MySQL, SQLite, MSSQL, and Oracle
Maintenance & Lineage 8 / 10

Well-known open-source xo/usql project under MIT license.

  • Active xo Go database tooling suite
Docs & Verifiability 8 / 10

Thorough README covering DSN syntax, supported drivers, and formatting flags, plus clear --help.

  • Comprehensive driver and flag reference in README

Security, Auth & Guardrails

Auth Modes
Env API Key Config File
Credential Storage

Reads credentials from DSN URIs (e.g., $DATABASE_URL), ~/.usqlpass, or ~/.pgpass-style files.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

MIT open-source Go CLI; free.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

Query any DSN database as JSON
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).

Export query results as CSV
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

Apply a SQL script non-interactively
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.
  • + -X and -q keep agent runs isolated from personal ~/.usqlrc configs.

Caveats & Pitfalls

  • ! Some specialized DB drivers (e.g., Oracle/ODBC) require build tags (-tags most/all) or external client libraries.
  • ! No universal --readonly switch; write safety relies on database user permissions.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI