# usql: A psql-Compatible CLI for PostgreSQL, MySQL, and Dozens More

> usql is a Go command-line tool that provides a psql-style interface to PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, and many other SQL and NoSQL databases from a single binary. It extends psql's model with syntax highlighting, context completion, and cross-database copy.

**xo/usql** — Universal command-line interface for SQL databases

- Repository: https://github.com/xo/usql
- Stars: 10,133 · Forks: 405
- Language: Go
- License: MIT
- Published: 2026-09-21 · Updated: 2026-09-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/xo-usql

## What usql Solves for Multi-Database Workflows

Database administrators who manage multiple database systems typically maintain separate client tools: psql for PostgreSQL, mysql for MySQL, sqlplus for Oracle. Each tool has its own command syntax, connection URL format, and backslash command set. usql provides one CLI for all of them, modelled on psql's interface. Connection strings use a URL format from the github.com/xo/dburl package, where the scheme identifies the database driver. Connecting to a local SQLite database looks like sqlite3://data/test.db, connecting to PostgreSQL looks like postgres://user@host/dbname, and connecting to MySQL looks like mysql://user@host/dbname. The README describes usql as supporting most core psql features including variables, backtick expressions, backslash commands, and has additional features that psql does not have, such as copying between databases, syntax highlighting, context-based completion, and terminal graphics.

## Installing usql via Homebrew, Go, or Docker

On macOS and Linux, the recommended installation is via the custom Homebrew tap.

```sh
brew install xo/xo/usql
```

For ODBC database support, add the --with-odbc flag during brew install. On Arch Linux, usql is in the AUR as usql-bin for a precompiled binary or usql to build from source. To install via Go with the base set of drivers.

```sh
go install github.com/xo/usql@latest
```

To include most drivers in the Go build.

```sh
go install -tags most github.com/xo/usql@latest
```

A Docker image is available at docker.io/usql/usql and can be run with Docker, Podman, or any OCI-compatible runtime.

```sh
docker run --rm -it --volume $(pwd)/data:/data docker.io/usql/usql:latest sqlite3://data/test.db
```

The Docker approach is useful on Windows or when driver compilation dependencies are not available.

## Build Tags and Driver Selection

usql uses Go build tags to control which database drivers are compiled into the binary. This design keeps binary size manageable when only a subset of drivers is needed. The base build includes PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, and CSVQ. The most tag includes most drivers except CGO drivers and drivers with known build issues. The all tag includes every driver.

```sh
go install -tags most github.com/xo/usql@main
```

Individual drivers can be added or excluded using their specific tag names. For example, adding Cassandra and removing Oracle from a most build uses `-tags 'most no_oracle cassandra'`. The driver listing in the go.mod file includes dozens of specific database packages: ClickHouse, DuckDB, Databricks, BigQuery via Spanner, Firebird, Hive, CockroachDB via the PostgreSQL driver, and many more. The \drivers command at runtime lists which drivers the current binary was built with.

## Variables, Backslash Commands, and Syntax Highlighting

usql implements psql's backslash command set for common operations: \d lists tables and schemas, \l lists databases, \c connects to a different database, \q quits, and \? displays help. These commands work the same way across all supported databases, which is the central value proposition. The go.mod file lists github.com/alecthomas/chroma as the syntax highlighting library, which colorizes SQL statements in the terminal as you type. Context-based completion suggests table names, column names, and SQL keywords based on the connected database's schema. Variables follow psql's syntax, and backtick expansion allows embedding shell command output in queries. The README describes terminal graphics support via the kenshaw/rasterm package, which renders images in terminals that support the Kitty graphics protocol or iTerm2 inline images.

## Copying Data Between Databases

One feature the README highlights as not available in psql is copying data between different database systems. usql can read from one database connection and write to another in a single session. This is useful for one-time migrations or synchronization tasks where importing from a file is not practical. The README does not provide a detailed example of the copy syntax in the text available, so consulting the full documentation is necessary for the exact command format. The go.mod includes drivers for many heterogeneous combinations: you can copy from a PostgreSQL table to a DuckDB file, or from a MySQL database to a SQLite file, using drivers compiled into the same binary. The cross-database capability depends on both source and target being supported drivers in the built binary.

## Limitations: CGO Drivers and No GUI

Some drivers require CGO, which means they require a C compiler and platform-specific libraries to build. These CGO drivers include the Oracle driver (godror, which requires Oracle Instant Client), SQLite3 with native linking, and ODBC. Environments without a C compiler or the necessary native libraries cannot build these drivers. The most tag excludes CGO drivers specifically to avoid this requirement. usql is a terminal application with no graphical interface. For database exploration with a point-and-click interface, tools like DBeaver or TablePlus are more appropriate. usql's --version command shows which drivers were compiled in, but the README notes that the \drivers command at runtime is the definitive list. The driver for a specific database may exist in go.mod but not be included in a given binary build depending on the build tags used.

## usql versus psql and Database-Specific Clients

psql is the official PostgreSQL client, developed by the PostgreSQL project and updated alongside each PostgreSQL release. It is the most complete client for PostgreSQL-specific features, including advanced backslash commands, COPY with format options, and integration with PostgreSQL-specific extensions. usql models its interface on psql but does not achieve full parity on PostgreSQL-specific commands. For MySQL, the official mysql client has features tied to MySQL-specific administration tasks. usql's advantage is the single consistent interface across all databases. For a developer who spends most of their time on PostgreSQL, psql is the better choice. For an administrator who manages PostgreSQL, MySQL, and Microsoft SQL Server, usql removes the need to switch tools.

## Conclusion

usql is the right tool for database administrators and developers who work across multiple database systems and want a single consistent CLI rather than learning a different client for each one. It is not the right choice when you need a graphical interface, or when your database driver requires CGO and your environment cannot compile native extensions. Before using it, install with the most tag to include all non-CGO drivers, and verify that your specific database appears in the driver listing with the \drivers command.

## FAQ

### What databases does usql support?

The base build includes PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, and CSVQ. With the most build tag, most non-CGO drivers are included, covering ClickHouse, DuckDB, Cassandra, Hive, Databricks, Firebird, and many others. The full list is available via the \drivers command at runtime.

### How is usql different from psql?

psql is the official PostgreSQL-only client with full support for PostgreSQL-specific commands and features. usql models its interface on psql and supports most core psql commands, but adds support for dozens of other database systems and features like syntax highlighting, context completion, and cross-database copy.

### How do I install usql with all database drivers?

Use go install -tags most github.com/xo/usql@latest to include most non-CGO drivers, or go install -tags all github.com/xo/usql@latest for all drivers including CGO ones. On macOS, brew install xo/xo/usql installs with most drivers included.

## Sources

- [Issues](https://github.com/xo/usql/issues)
- [License: MIT](https://github.com/xo/usql/blob/main/LICENSE)
- [README](https://github.com/xo/usql/blob/main/README.md)
- [Releases](https://github.com/xo/usql/releases)
- [xo/usql on GitHub](https://github.com/xo/usql)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/xo-usql
