# usql

> Universal command-line SQL client with PostgreSQL psql-inspired interface for multiple databases

Stars: 10.2k · Language: Go · License: MIT · Categories: Data

- Repository: https://github.com/xo/usql
- Page: https://www.trmn.sh/tools/usql

## Install

- Homebrew: `brew install xo/xo/usql`
- Go: `go install github.com/xo/usql@latest`
- Docker: `docker run --rm -it docker.io/usql/usql:latest`

## Overview

usql is a universal command-line SQL client that provides a psql-compatible interface for working with multiple database systems. It supports PostgreSQL, MySQL, Oracle, SQLite3, Microsoft SQL Server, and many other SQL and NoSQL databases through a single unified interface. The tool replicates most core psql features including variables, backticks, and backslash commands while extending functionality with multi-database support and database-to-database copying.

The client includes syntax highlighting, context-based completion, and terminal graphics capabilities that enhance the interactive experience beyond what psql offers. Database administrators and developers can use the same familiar psql-style commands across different database systems, eliminating the need to learn multiple database-specific CLI tools.

usql supports over 30 database drivers through Go's SQL interface, with build tags allowing users to compile only the drivers they need. The tool can be built with base drivers (PostgreSQL, MySQL, SQLite3, SQL Server, Oracle, CSVQ), most drivers, or all available drivers including CGO-dependent ones. Installation options include system package managers, Go toolchain, and Docker containers.

### Installation

```bash
# via Homebrew
brew install xo/xo/usql
```

```bash
# via Go
go install github.com/xo/usql@latest
```

```bash
# via Docker
docker run --rm -it docker.io/usql/usql:latest
```

## Alternatives

- [miller](https://www.trmn.sh/tools/miller.md): Command-line data processing tool for CSV, TSV, JSON, and JSON Lines with field-based operations (Go, 10.1k stars)
- [pup](https://www.trmn.sh/tools/pup.md): Command line HTML processing tool using CSS selectors to filter and extract data from HTML documents (Go, 8.4k stars)
- [dasel](https://www.trmn.sh/tools/dasel.md): Command-line tool for querying, modifying, and transforming structured data files (JSON, YAML, TOML, XML, CSV) (Go, 8.1k stars)
- [jid](https://www.trmn.sh/tools/jid.md): Interactive JSON explorer that takes piped input and lets you drill down with dot-path or JMESPath queries, with tab completion and suggestions. (Go, 7.2k stars)
- [gron](https://www.trmn.sh/tools/gron.md): Transforms JSON into discrete assignments to make it greppable and enable exploration of complex JSON structures (Go, 14.5k stars)

## Guides

- [Best Database CLI Clients](https://www.trmn.sh/best/database-clients): Compare usql, pgcli, mycli, harlequin and lazysql for querying Postgres, MySQL and SQLite from the terminal, with notes on dblab.

---

Canonical: https://www.trmn.sh/tools/usql
