Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
U

usql

> 数据库
Open source

Universal command-line interface for SQL databases

10.1K stars0 likes1 views
WebsiteGitHub

About

Universal command-line interface for SQL databases


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]:

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

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

bash
# 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]:

bash
# install usql with most drivers
$ yay -S usql

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

bash
$ 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:

powershell
# 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:

bash
# 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:

…

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:

bash
# 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.

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

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

bash
# 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:

bash
# 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]:

bash
$ 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
PostgreSQL postgres pg, pgsql, postgresql [github.com/lib/pq][d-postgres]
MySQL mysql my, maria, aurora, mariadb, percona [github.com/go-sql-driver/mysql][d-mysql]
Microsoft SQL Server sqlserver ms, mssql, azuresql [github.com/microsoft/go-mssqldb][d-sqlserver]
Oracle Database oracle or, ora, oci, oci8, odpi, odpi-c [github.com/sijms/go-ora/v3][d-oracle]
SQLite3 sqlite3 sq, sqlite, file [github.com/mattn/go-sqlite3][d-sqlite3] [†][f-cgo]
ClickHouse clickhouse ch [github.com/ClickHouse/clickhouse-go/v2][d-clickhouse]
CSVQ csvq cs, csv, tsv, json [github.com/mithrandie/csvq-driver][d-csvq]
Alibaba MaxCompute maxcompute mc [sqlflow.org/gomaxcompute][d-maxcompute]
Alibaba Tablestore ots ot, tablestore [github.com/aliyun/aliyun-tablestore-go-sql-driver][d-ots]
Apache Avatica avatica av, phoenix [github.com/apache/calcite-avatica-go/v5][d-avatica]
Apache H2 h2 [github.com/jmrobles/h2go][d-h2]
Apache Hive hive hi, hive2 [sqlflow.org/gohive][d-hive]
Apache Ignite ignite ig, gridgain [github.com/amsokol/ignite-go-client/sql][d-ignite]
Apache Impala impala im [github.com/sclgo/impala-go][d-impala]
AWS Athena athena s3, aws, awsathena [github.com/uber/athenadriver/go][d-athena]
Azure CosmosDB cosmos cm, gocosmos [github.com/btnguyen2k/gocosmos][d-cosmos]
Cassandra cassandra ca, scy, scylla, datastax, cql [github.com/MichaelS11/go-cql-driver][d-cassandra]
ChaiSQL chai ci, genji, chaisql [github.com/chaisql/chai][d-chai]
Couchbase couchbase n1, n1ql [github.com/couchbase/go_n1ql][d-couchbase]
Cznic QL ql cznic, cznicql [modernc.org/ql][d-ql]
Dameng DM8 dameng dm, dm8 [github.com/godoes/gorm-dameng/dm8][d-dameng]
Databend databend dd, bend [github.com/datafuselabs/databend-go][d-databend]
Databricks databricks br, brick, bricks, databrick [github.com/databricks/databricks-sql-go][d-databricks]
DuckDB duckdb dk, ddb, duck, file [github.com/duckdb/duckdb-go/v2][d-duckdb] [†][f-cgo]
DynamoDb dynamodb dy, dyn, dynamo, dynamodb [github.com/btnguyen2k/godynamo][d-dynamodb]
Exasol exasol ex, exa [git

Issues· 60 open

View all issuesOpen on GitHub
  • #540

    Feature: add `UPDATE ... RETURNING` support

    Updated Sep 23, 2026
  • #546

    busy loop cpu 100%

    readlineUpdated Sep 23, 2026
  • #72

    History filtering

    readlineUpdated Sep 23, 2026
  • #320

    Improve query history navigation

    readlineUpdated Sep 23, 2026
  • #414

    .usql_history file appears corrupt, no newlines saved?

    readlineUpdated Sep 23, 2026
  • #528

    Consider using readline library from github.com/chzyer/readline

    readlineUpdated Sep 23, 2026
  • #215

    \echo and \warn -n problem on interactive

    bughelp wantedpsql compatreadlineUpdated Sep 23, 2026
  • #472

    Can't send tab character as input

    readlineUpdated Sep 23, 2026
  • #552

    Integrate readline vim mode

    readlineUpdated Sep 23, 2026
  • #508

    Input frequently alternates between pager and prompt

    readlineUpdated Sep 23, 2026

> Tags

Gocommand-linedatabasegogolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库