ConfigsApr 21, 2026·3 min read

usql — Universal Command-Line SQL Client for Every Database

A universal command-line interface for PostgreSQL, MySQL, SQLite, Oracle, SQL Server, and 40+ other databases with auto-completion and consistent syntax.

Agent ready

Safe staging for this asset

This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.

Stage only · 17/100Policy: stage
Agent surface
Any MCP/CLI agent
Kind
CLI Tool
Install
Stage only
Trust
Trust: Established
Entrypoint
usql Overview
Safe staging command
npx -y tokrepo@latest install bac4c91b-3d5a-11f1-9bc6-00163e2b0d79 --target codex

Stages files first; activation requires review of the staged README and plan.

Introduction

usql is a universal command-line SQL client inspired by psql. It provides a single binary that connects to PostgreSQL, MySQL, SQLite, SQL Server, Oracle, CockroachDB, and over 40 other database engines using a consistent URL-based connection string format. Instead of installing and learning separate CLI tools for each database, developers use one tool with familiar readline editing, tab completion, and backslash meta-commands across all supported engines.

What usql Does

  • Connects to 40+ database engines through a unified URL connection string syntax
  • Provides psql-style backslash commands (d, dt, di, l) that work across databases
  • Supports readline-based editing with tab completion for tables and columns
  • Outputs query results in multiple formats: aligned, CSV, JSON, HTML, and vertical
  • Executes SQL scripts from files with variable substitution and conditional logic

Architecture Overview

usql is a single Go binary that dynamically loads database drivers at compile time. Each connection URL scheme (postgres://, mysql://, sqlite://) maps to the appropriate Go database/sql driver. The shell layer wraps the driver with readline support, backslash command parsing, and output formatting. Metadata introspection commands are translated to the appropriate INFORMATION_SCHEMA or catalog queries for each engine.

Self-Hosting & Configuration

  • Install a single static binary with no runtime dependencies
  • Set USQL_DSN environment variable for a default connection
  • Configure .usqlrc for startup commands, prompt format, and output preferences
  • Use copy to import and export CSV data across different database types
  • Pass -c for non-interactive single-command execution in scripts

Key Features

  • One binary replaces psql, mysql, sqlite3, sqlcmd, and dozens of other clients
  • Consistent backslash commands for schema introspection across all engines
  • Copy data between different database types with copy
  • Syntax highlighting and auto-completion in the interactive shell
  • Supports ODBC and ADODB for connecting to any database with a driver

Comparison with Similar Tools

  • psql — PostgreSQL only; usql covers 40+ databases with similar UX
  • mycli / pgcli — single-database CLIs with rich auto-complete; usql trades depth for breadth
  • DBeaver — full GUI client; usql is terminal-native and scriptable
  • dbcli — Python-based per-database CLIs; usql is a single Go binary for all
  • DataGrip — commercial IDE; usql is free, lightweight, and shell-friendly

FAQ

Q: Which databases does usql support? A: Over 40 engines including PostgreSQL, MySQL, SQLite, SQL Server, Oracle, CockroachDB, Cassandra, MongoDB, Snowflake, BigQuery, ClickHouse, and more.

Q: Can I use usql in scripts? A: Yes. Use usql -c "SELECT ..." postgres://... for one-shot queries, or pipe SQL files with usql postgres://... < script.sql.

Q: Does it support SSH tunneling? A: usql itself does not handle SSH tunneling, but you can use standard SSH port forwarding and connect to the forwarded local port.

Q: How do I switch output format? A: Use pset format csv or pset format json to change the output format within a session.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets