home / databases / usql

usql

9.9k

Universal SQL client for querying many databases with psql-style commands, scripts, and cross-database copy.

$brew install xo/xo/usql
Language
Go
Stars
9,852
Category
Databases
Agent
Ready
Agent Compatibility
JSON Output
Agent Skill
MCP Support
AI Analysis

usql is a psql-inspired database shell that talks to many SQL backends through Go SQL drivers and dburl-style DSNs. It works as both an interactive client and a scriptable query runner when you need one command surface across heterogeneous databases.

What It Enables
  • Run ad hoc queries or SQL files against PostgreSQL, MySQL, SQLite, SQL Server, Oracle, and many other supported backends from one CLI.
  • Inspect schemas, tables, functions, indexes, and connection metadata with psql-style meta commands instead of learning each database's native client.
  • Copy query results between databases, or import CSV-backed data into a destination table, with \copy and dburl DSNs.
Agent Fit
  • -c, -f, --no-init, --no-password, and -q give agents a workable non-interactive path once DSNs and credentials are already known.
  • -J enables JSON formatting for query results, but connection messages, errors, and some meta-command flows still come back as plain text.
  • Best for workflows that already know the target database and query shape; available drivers and metadata behavior vary by build tags and backend.
Caveats
  • Driver coverage depends on how the binary was built: plain go install includes base drivers, while release and Homebrew builds include more.
  • \copy is not a drop-in clone of psql's version and does not perform datatype conversion, so cross-database transfers may need explicit casts.