usql is a free, open source databases project written in Go and released under MIT. It has 10,118 GitHub stars, 406 forks and 121 open issues, and was last pushed 5 days ago. On this registry it ranks #79 of 143 tracked projects in Databases, with 5 head-to-head comparisons available.

What is usql?

usql is a universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server and many other SQL and NoSQL databases, built for database administrators and developers who want the familiar psql experience when working against databases other than PostgreSQL.

What it is

usql is an open-source command-line client written in Go and released under the MIT licence. It presents a single interactive shell for querying and administering a wide range of relational and non-relational databases, including PostgreSQL, MySQL, MariaDB, Oracle Database, SQLite3 and Microsoft SQL Server. Its interface is modelled on psql, PostgreSQL's own terminal client, so the vocabulary of variables, backticks and backslash commands carries over intact. The project is distributed as prebuilt releases and through package managers rather than as a hosted service.

The concrete problem usql solves is client sprawl. Every database engine normally ships its own command-line tool, each with its own flags, its own history file, its own escaping rules and its own scripting conventions, so a team running several engines must context-switch between incompatible shells. usql replaces those per-engine clients with one binary that speaks the same command language across all of them, and it goes beyond psql by supporting multiple database connections at once, copying data between databases, syntax highlighting, context-based completion and terminal graphics.

Key capabilities

  • Supports most core psql features, including variables, backticks and backslash commands, so existing psql habits transfer directly.
  • Connects to many database engines from one binary, covering PostgreSQL, MySQL, MariaDB, Oracle Database, SQLite3 and Microsoft SQL Server alongside NoSQL and non-relational systems.
  • Opens multiple databases simultaneously and copies data between them within a single session.
  • Provides interactive conveniences absent from psql, such as syntax highlighting, context-based completion and terminal graphics.
  • Reaches ODBC-accessible databases through build support, enabled on Homebrew installs with the --with-odbc flag.
  • Ships through many channels: prebuilt .tar.bz2 and .zip releases, Homebrew via the xo/xo tap, the Arch Linux AUR, Scoop on Windows, go install and Docker.
  • Uses build tags to select which database drivers are compiled into a given binary, so builds can be tuned to the engines a deployment actually needs.

Who uses it and how

  • Database administrators and developers who prefer a psql-style workflow but who spend most of their time in MySQL, Oracle Database or SQL Server.
  • Teams operating heterogeneous estates, where a single engineer may need to query PostgreSQL and SQL Server in the same working session, or move rows between them.
  • Shell and automation workflows, since the backslash command set and variable support allow repeatable command scripts rather than ad hoc interactive typing.
  • Container-based environments, where the Docker install path provides a client without adding a package manager dependency to the image.
  • Workstations across platforms: macOS and Linux users typically take it from Homebrew or the AUR, while Windows users install it with Scoop.

Getting started

Install with brew install xo/xo/usql for most drivers, or go install github.com/xo/usql@latest for a base-driver build; prebuilt release archives and a Docker image are also published.

How it compares

The only comparable tool named in the project's own documentation is psql, which is the model usql imitates rather than a product it displaces. psql works against PostgreSQL alone, whereas usql keeps the same command vocabulary and adds engine coverage, multi-database sessions and cross-database copying. For the command-line clients shipped by other database vendors, usql positions itself as a direct replacement.

When to use it — and when not to

A self-hoster must supply a Go toolchain or a supported package manager, choose the driver build tags that match the target engines, and rebuild when ODBC or other optional drivers are required; like any client, it also needs network reachability and credentials for every database it connects to. It is a poor fit for anyone who wants a graphical query browser, and the project carries a substantial backlog of open issues, currently 121. Because it is a client rather than a server, it brings no storage, scheduling or access-control layer of its own.

project readme (upstream, from github) — read inline

Installing | Building | Database Support | Using | Features and Compatibility | Releases | Contributing


usql is a universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server, and many other databases including NoSQL and non-relational databases!

usql provides a simple way to work with SQL and NoSQL databases via a command-line inspired by PostgreSQL's psql. usql supports most of the core psql features, such as [variables][variables], [backticks][backticks], [backslash commands][commands] and has additional features that psql does not, such as multiple database support, [copying between databases][copying], [syntax highlighting][highlighting], [context-based completion][completion], and [terminal graphics][termgraphics].

Database administrators and developers that would prefer to work with a tool like psql with non-PostgreSQL databases, will find usql intuitive, easy-to-use, and a great replacement for the command-line clients/tools for other databases.

Unit Tests Go Reference Releases Discord Discussion

Installing

usql can be installed via Release, via Homebrew, via AUR, via Scoop, via Go, or via Docker:

Installing via Release

  1. Download a release for your platform
  2. Extract the usql or usql.exe file from the .tar.bz2 or .zip file
  3. Move the extracted executable to somewhere on your $PATH (Linux/macOS) or %PATH% (Windows)

Installing via Homebrew (macOS and Linux)

Install usql from the [xo/xo tap][xo-tap] in the usual way with the [brew command][homebrew]:

# install usql with most drivers
$ brew install xo/xo/usql

Support for ODBC databases is available through the --with-odbc install flag:

# add xo tap
$ brew tap xo/xo

# install usql with odbc support
$ brew install --with-odbc usql

Installing via AUR (Arch Linux)

Install usql from the [Arch Linux AUR][aur] in the usual way with the [yay command][yay]:

# install usql with most drivers
$ yay -S usql

Alternately, build and [install using makepkg][arch-makepkg]:

$ git clone https://aur.archlinux.org/usql.git && cd usql
$ makepkg -si
==> Making package: usql 0.12.10-1 (Fri 26 Aug 2022 05:56:09 AM WIB)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading usql-0.12.10.tar.gz...
...

Installing via Scoop (Windows)

Install usql using Scoop:

# Optional: Needed to run a remote script the first time
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

# install scoop if not already installed
> irm get.scoop.sh | iex

# install usql with scoop
> scoop install usql

Installing via Go

Install usql in the usual Go fashion:

# install latest usql version with base drivers
$ go install github.com/xo/usql@latest

# alternately, install usql with most drivers (see below for info about build tags)
$ go install -tags most github.com/xo/usql@latest

See below for information on usql build tags.

Installing via Docker

An official container image (docker.io/usql/usql) is maintained by the usql team, and can be used with Docker, Podman, or other container runtime.

Install usql with Docker, Podman, or other container runtime:

# run interactive shell and mount the $PWD/data directory as a volume for use
# within the container
$ docker run --rm -it --volume $(pwd)/data:/data docker.io/usql/usql:latest sqlite3://data/test.db
Trying to pull docker.io/usql/usql:latest...
Getting image source signatures
Copying blob af48168d69d8 done   |
Copying blob efc2b5ad9eec skipped: already exists
Copying config 917ceb411d done   |
Writing manifest to image destination
Connected with driver sqlite3 (SQLite3 3.45.1)
Type "help" for help.

sq:data/test.db=> \q

# run postgres locally
$ docker run --detach --rm --name=postgres --publish=5432:5432 --env=POSTGRES_PASSWORD=P4ssw0rd docker.io/usql/postgres

# connect to local postgres instance
$ docker run --rm --network host -it docker.io/usql/usql:latest postgres://postgres:P4ssw0rd@localhost
Connected with driver postgres (PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1))
Type "help" for help.

pg:postgres@localhost=> \q

# run specific usql version
$ docker run --rm -it docker.io/usql/usql:0.19.3

Building

When building usql out-of-the-box with go build or go install, only the base drivers for PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, CSVQ will be included in the build:

# build/install with base drivers (PostgreSQL, MySQL, SQLite3, Microsoft SQL Server,
# Oracle, CSVQ)
$ go install github.com/xo/usql@main

Other databases can be enabled by specifying the build tag for their database driver.

# build/install with base, Avatica, and ODBC drivers
$ go install -tags 'avatica odbc' github.com/xo/usql@main

For every build tag ``, there is also a no_ build tag that will disable the driver:

# build/install most drivers, excluding Avatica, Couchbase, and PostgreSQL
$ go install -tags 'most no_avatica no_couchbase no_postgres' github.com/xo/usql@main

By specifying the build tags most or all, the build will include most, and all SQL drivers, respectively:

# build/install with most drivers (excludes CGO drivers and problematic drivers)
$ go install -tags most github.com/xo/usql@main

# build/install all drivers (includes CGO drivers and problematic drivers)
$ go install -tags all github.com/xo/usql@main

Database Support

usql works with all Go standard library compatible SQL drivers supported by [github.com/xo/dburl][dburl].

The list of drivers that usql was built with can be displayed with the [\drivers command][commands]:

$ cd $GOPATH/src/github.com/xo/usql

# build excluding the base drivers, and including cassandra and moderncsqlite
$ go build -tags 'no_postgres no_oracle no_sqlserver no_sqlite3 cassandra moderncsqlite'

# show built driver support
$ ./usql -c '\drivers'
Available Drivers:
  cql [ca, scy, scylla, datastax, cassandra]
  memsql (mysql) [me]
  moderncsqlite [mq, sq, file, sqlite, sqlite3, modernsqlite]
  mysql [my, maria, aurora, mariadb, percona]
  tidb (mysql) [ti]
  vitess (mysql) [vt]

The above shows that usql was built with only the mysql, cassandra (ie, cql), and moderncsqlite drivers. The output above reflects information about the drivers available to usql, specifically the internal driver name, its primary URL scheme, the driver's available scheme aliases (shown in [...]), and the real/underlying driver (shown in (...)) for wire compatible drivers.

Supported Database Schemes and Aliases

The following are the [Go SQL drivers][go-sql] that usql supports, the associated database, scheme / build tag, and scheme aliases:

| Database | Scheme / Tag | Scheme Aliases | Driver Package / Notes | | -------------------- | ---------

readme truncated — read the full docs on github

Frequently asked questions

Is usql free to use?

usql is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does usql do?

Universal command-line interface for SQL databases

What is usql written in?

usql is primarily written in Go. Its source is publicly available at https://github.com/xo/usql, and it has 10,118 GitHub stars.