MCPcopy Index your code
hub / github.com/xo/usql

github.com/xo/usql @v0.21.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.21.4 ↗ · + Follow
829 symbols 2,878 edges 142 files 374 documented · 45% updated 17d agov0.21.4 · 2026-03-26★ 10,02794 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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@master

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@master

For every build tag <driver>, there is also a no_<driver> 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@master

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@master

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

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
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/v2][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]
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 [github.com/exasol/exasol-driver-go][d-exasol]
Firebird firebird fb, firebirdsql [github.com/nakagami/firebirdsql][d-firebird]
FlightSQL flightsql fl, flight [github.com/apache/arrow/go/v17/arrow/flight/flightsql/driver][d-flightsql]
Google BigQuery bigquery bq

Extension points exported contracts — how you extend this code

CatalogReader (Interface)
CatalogReader lists database schemas. [7 implementers]
drivers/metadata/metadata.go
Handler (Interface)
Handler is the shared interface for a command handler. [1 implementers]
metacmd/types.go
IO (Interface)
IO is the common input/output interface. [1 implementers]
rline/rline.go
ContextExecutor (Interface)
ContextExecutor is the command context.
run.go
Option (FuncType)
Option is a statement buffer option.
stmt/stmt.go
DB (Interface)
DB is the common interface for database operations, compatible with database/sql.DB and database/sql.Tx.
drivers/drivers.go
Option (FuncType)
Option to configure the reader
drivers/completer/completer.go
FS (Interface)
FS is the filesystem interface.
handler/handler.go

Core symbols most depended-on inside this repo

Next
called by 85
drivers/completer/completer.go
Get
called by 76
drivers/metadata/metadata.go
Scan
called by 56
drivers/metadata/metadata.go
Err
called by 50
drivers/metadata/metadata.go
TailMatches
called by 47
drivers/completer/completer.go
Register
called by 44
drivers/drivers.go
Err
called by 39
drivers/pgx/pgx.go
CompleteFromList
called by 35
drivers/completer/completer.go

Shape

Method 353
Function 336
Struct 90
Interface 33
TypeAlias 10
FuncType 7

Languages

Go100%

Modules by API surface

drivers/metadata/metadata.go144 symbols
handler/handler.go55 symbols
drivers/drivers.go47 symbols
drivers/completer/completer.go41 symbols
metacmd/types.go38 symbols
drivers/metadata/reader.go36 symbols
drivers/metadata/writer.go35 symbols
drivers/metadata/informationschema/metadata.go34 symbols
rline/rline.go25 symbols
env/types.go25 symbols
run.go22 symbols
stmt/stmt.go19 symbols

Dependencies from manifests, versioned

cel.dev/exprv0.25.1 · 1×
cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/bigqueryv1.74.0 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
cloud.google.com/go/longrunningv0.8.0 · 1×
cloud.google.com/go/monitoringv1.24.3 · 1×
cloud.google.com/go/spannerv1.88.0 · 1×
dario.cat/mergov1.0.2 · 1×
filippo.io/edwards25519v1.1.0 · 1×

Datastores touched

(mysql)Database · 1 repos
postgresDatabase · 1 repos
dbnameDatabase · 1 repos
sakilaDatabase · 1 repos
booktestDatabase · 1 repos
dbnameDatabase · 1 repos

For agents

$ claude mcp add usql \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact