Currently viewing the human version
Switch to AI version

What usql Actually Is (And When It'll Drive You Nuts)

Look, usql is basically someone's attempt to create one database client to rule them all. The idea is solid: instead of juggling psql, mysql, sqlite3, and whatever the fuck Oracle calls their client these days, you get one tool that connects to everything.

Does it work? Mostly. Will it occasionally make you want to throw your laptop out the window? Absolutely.

The Problem usql Tries to Solve

If you've worked with databases for more than five minutes, you know this pain: every database has its own special snowflake client. PostgreSQL has psql (which is actually decent), MySQL has that mysql command that never remembers your password correctly, and don't get me started on Oracle's sqlplus - that thing feels like it was designed by someone who hates developers.

So you end up with:

How usql Actually Works (When It Works)

usql takes the psql interface - which most people actually like - and bolts on drivers for 40+ database systems. Version 0.19.25 connects to basically everything that speaks SQL and some things that don't.

Database Driver Architecture

Like most Go database tools, usql builds on the standard database/sql package architecture. The universal client provides a consistent interface while different database drivers handle the backend-specific communication protocols.

The good parts:

The parts that'll bite you:

When You Should Actually Use This

usql shines when you're:

When to just use the native client instead:

The bottom line: usql is useful enough that I keep it installed, but I still have psql and mysql as backups for when things go sideways.

Supported Database Systems

Database Category

Systems Supported

Connection Schemes

Traditional SQL

PostgreSQL, MySQL, Oracle Database, Microsoft SQL Server, SQLite

postgres://, mysql://, oracle://, sqlserver://, sqlite3://

Cloud SQL

Amazon Redshift, Google BigQuery, Google Spanner, Azure SQL, Snowflake

redshift://, bigquery://, spanner://, azuresql://, snowflake://

Analytics

ClickHouse, Apache Presto, Trino, Apache Impala, Databricks

clickhouse://, presto://, trino://, impala://, databricks://

NoSQL

Cassandra, Couchbase, DynamoDB, Azure CosmosDB

cassandra://, couchbase://, dynamodb://, cosmos://

Data Warehouses

Apache Hive, Alibaba MaxCompute, AWS Athena, Vertica

hive://, maxcompute://, athena://, vertica://

Embedded

SQLite3, DuckDB, ModernC SQLite, ChaiSQL

sqlite://, duckdb://, moderncsqlite://, chai://

Legacy/Specialized

SAP HANA, SAP ASE, Firebird, Apache H2, CSVQ

saphana://, sapase://, firebird://, h2://, csvq://

Installation: The Easy Part (Until It Isn't)

Installing usql should be straightforward, but like everything in software, there are gotchas waiting to ruin your day.

The "Just Works" Methods

Homebrew (macOS/Linux) - Start here

## This works 90% of the time
brew install xo/xo/usql

If you need ODBC support (and you probably don't), there used to be a --with-odbc flag but Homebrew killed that. Now you're stuck building from source.

Docker - When you give up on local installation

## Basic usage - mount your data directory
docker run --rm -it --volume $(pwd):/data docker.io/usql/usql:latest

## Connect to host database (networking can be a pain)
docker run --rm --network host -it docker.io/usql/usql:latest postgres://user:pass@localhost/db

Docker networking will fuck you if your database is running in another container. Use `docker-compose` or give up and install locally.

The "I Like Pain" Method: Building from Source

Go installation - Pick your poison

## Minimal drivers, less likely to break
go install github.com/xo/usql@latest

## Most drivers, good balance of features vs. stability
go install -tags most github.com/xo/usql@latest

## All drivers, prepare for CGO hell
go install -tags all github.com/xo/usql@latest

Real talk about build tags:

  • `base`: PostgreSQL, MySQL, SQLite, SQL Server, Oracle. Safe choice.
  • `most`: Everything except the problematic CGO drivers. This is what you want.
  • `all`: Everything including Oracle ODBC and other CGO nightmares. Only do this if you enjoy suffering.

When Things Go Wrong (And They Will)

ARM64 build failures
If you're on Apple Silicon or ARM, builds randomly fail with:

undefined reference to `resvg_parse_tree_from_data'

This is a known issue #494. Try the most build tag instead of all.

macOS config directory confusion
The docs lie. They say config goes in ~/.config/usql but on macOS it actually looks in:

~/Library/Application Support/usql/config.yaml

This bit me for hours before I figured it out.

CGO dependency hell
If you see errors about missing C libraries, you're in CGO land:

## macOS - might help with ICU4C issues
brew install icu4c

## Still broken? Try the nuclear option
export CGO_ENABLED=0
go install -tags most github.com/xo/usql@latest

First Connection Reality Check

PostgreSQL - Usually works

## Local with defaults (if you're lucky)
usql pg://

## More likely you need this
usql postgres://user:password@localhost:5432/database

## SSL issues? Disable it
usql pg://user:pass@host/db?sslmode=disable

MySQL - Password encoding will get you

## Basic connection
usql mysql://user:password@localhost/database

## Special characters in password? URL encode that shit
usql mysql://user:p%40ssw0rd@localhost/database

SQLite - The reliable one

## Just point at a file
usql database.sqlite3

## Or be explicit
usql sqlite3://./database.db

Quick Sanity Check

## Make sure it actually installed
usql --version

## See what drivers you actually got
usql -c '\drivers'

## Test basic connection
usql sqlite3://test.db -c 'SELECT "hello world";'

If any of these fail, you're probably missing dependencies or hit a build issue. Welcome to the wonderful world of Go CGO dependencies.

Pro tip: Keep both usql and the native clients installed. When usql breaks (and it will), you'll be glad you have `psql` as backup.

Features That Work (And Ones That Don't)

usql tries to be the Swiss Army knife of database clients. Sometimes it succeeds, sometimes it cuts you.

The psql-Compatible Stuff (Mostly Works)

Backslash commands - The good part
Most of PostgreSQL's `\` commands work across databases:

  • `\d` - Lists tables, but formatting varies wildly by database
  • `\dt` - Tables specifically (when the driver supports it)
  • `\c` - Connect to different databases (connection strings are a pain)
  • ` iming` - Shows query timing (actually useful)
  • `\help` - Decent help system

Query buffer stuff

Auto-Completion: Hit or Miss

The auto-completion is... optimistic. Works great with PostgreSQL, decent with MySQL, and completely shits the bed with anything exotic. Don't rely on it for Oracle or any of the NoSQL adapters.

What actually completes:

  • SQL keywords (usually)
  • Table names (if you're connected to PostgreSQL or MySQL)
  • Column names (sometimes, if the stars align)

What doesn't:

  • Database-specific functions
  • Anything in BigQuery or Snowflake
  • Complex schema names with dots

Syntax Highlighting: Pretty but Buggy

Powered by Chroma, which is nice when it works. But complex queries break the parser and you get rainbow vomit instead of useful highlighting.

## Turn it off when it annoys you
\set SYNTAX_HL false

Output Formats: The Actually Useful Part

Multiple output modes that actually work:

  • Default aligned tables (good for human consumption)
  • `\json` - JSON output (great for scripts)
  • `\csv` - CSV export (works better than most native clients)
  • `\G` - Vertical display (lifesaver for wide tables)
  • `\H` - HTML tables (useful for reports)

Cross-Database Copy: When It Doesn't Crash

The `\copy` command is usql's killer feature, but it's also where most of the pain happens:

-- This works (usually)
\copy postgres://source mysql://target 'SELECT * FROM small_table' 'backup_table'

-- This will timeout or crash
\copy postgres://source mysql://target 'SELECT * FROM huge_table' 'backup_table'

Reality check:

  • Great for small datasets (< 100MB)
  • Timeouts on anything substantial
  • No progress indicators, so you're flying blind
  • Error messages are cryptic as hell

Configuration: macOS Will Betray You

Remember that config file location issue? It gets worse:

Linux/WSL:

## ~/.config/usql/config.yaml
connections:
  prod: postgres://user:pass@prod-host/db

macOS (the special snowflake):

## ~/Library/Application Support/usql/config.yaml
connections:
  prod: postgres://user:pass@prod-host/db

The .usqlpass file for password storage works, but good luck remembering the format:

## protocol:host:port:database:user:password
postgres:localhost:5432:mydb:myuser:mypass
mysql:*:*:*:myuser:mypass

What's Actually Missing

No connection pooling - Each connection is brand new
No transaction state preservation - Switching connections kills your transaction
Spotty schema support - Multi-schema databases are a nightmare
No query history persistence - Restart usql, lose your history
Performance monitoring - iming is basic, no detailed stats

Terminal Graphics: Gimmicky

The "terminal graphics" and chart generation features exist, but they're mostly novelty. Unless you're presenting to someone who's never seen a database client before, just export to CSV and use real visualization tools.

When to Use Native Clients Instead

Use `psql` when:

Use `mysql` when:

Use usql when:

  • Jumping between different database types
  • Quick ad-hoc queries across systems
  • Data migration between different databases
  • You're too lazy to remember different client syntaxes

Bottom line: usql is a decent Swiss Army knife, but sometimes you need an actual screwdriver.

Questions People Actually Ask (And the Real Answers)

Q

Why does my config file not work on macOS?

A

The documentation lies to you. It says config goes in ~/.config/usql/config.yaml but on macOS it actually uses ~/Library/Application Support/usql/config.yaml. This bit me for 3 hours until I dug through the source code.

If you have $XDG_CONFIG_HOME set, it should take precedence, but it doesn't. Welcome to macOS special case hell.

Q

Why did Presto stop working after upgrading?

A

Version 0.19.24 completely broke Presto support. Queries execute fine on the Presto server but usql can't parse the results. The fix? Downgrade to 0.11 or wait for them to fix it.

This is why you pin versions in production. Always.

Q

Why does my Go build fail with `undefined reference to resvg_parse_tree_from_data`?

A

You're hitting the ARM64 build issue. The all build tag tries to compile graphics libraries that don't work on ARM. Known problem #494.

## Use this instead
go install -tags most github.com/xo/usql@latest
Q

How the hell do I remember the .usqlpass file format?

A

You don't. Just bookmark this:

## protocol:host:port:database:user:password
postgres:localhost:5432:mydb:myuser:mypass
mysql:*:*:*:myuser:mypass
oracle:prod-host:1521:orcl:myuser:mypass

The * means "any". Don't ask me why they chose this format.

Q

Why does \copy timeout on large tables?

A

Because it's doing a naive SELECT and INSERT without any streaming or progress indication. Anything over 100MB will probably timeout. No progress bar, no way to resume, no nothing.

For large datasets, use native tools:

## PostgreSQL to MySQL the hard way
pg_dump --data-only --table=users mydb | mysql target_db
Q

Why doesn't auto-completion work with [database]?

A

Auto-completion is a crapshoot outside of PostgreSQL and MySQL. BigQuery, Snowflake, Oracle? Forget about it. The completion engine only knows how to introspect a few database types properly.

If tab completion is mission-critical for your workflow, stick with native clients.

Q

Can I use this in production?

A

Depends on your definition of "production." I use it for:

  • Quick data exploration
  • One-off migrations between databases
  • Ad-hoc reporting

I DON'T use it for:

  • High-performance data processing
  • Mission-critical ETL pipelines
  • Anything where connection pooling matters
  • Complex transaction workflows
Q

Why does syntax highlighting break on complex queries?

A

The Chroma parser chokes on anything complex - nested CTEs, long case statements, or weird vendor extensions. You get rainbow vomit instead of useful highlighting.

## Turn it off
\set SYNTAX_HL false
Q

What's the deal with different build tags?

A
  • base: Basic drivers (PostgreSQL, MySQL, SQLite, SQL Server, Oracle)
  • most: Everything except CGO nightmares (recommended)
  • all: Everything including ODBC and graphics libs (will break on ARM)

If you're not sure, use most. If you only use PostgreSQL and MySQL, use base.

Q

How do I debug "invalid database scheme" errors?

A

This usually means:

  1. You typo'd the connection string
  2. The driver isn't compiled in your build
  3. You're using the wrong scheme format
## Check what drivers you actually have
usql -c '\drivers'

## Test with a simple SQLite connection
usql test.db
Q

Why is the terminal graphics stuff useless?

A

Because it's a gimmick. The chart generation only works in specific terminals with graphics support, the output looks like ASCII art from 1995, and you can't export or save anything.

Just use CSV export and proper visualization tools:

## Export to CSV, use real tools
usql db -c 'SELECT * FROM metrics' --csv > data.csv
Q

Should I learn usql or stick with native clients?

A

Learn both. Use usql when jumping between database types or doing cross-database operations. Use native clients (psql, mysql, etc.) when you need performance, advanced features, or database-specific tools.

Having both in your toolkit means you're never stuck when one doesn't work.

Official Resources and Documentation

Related Tools & Recommendations

compare
Recommended

PostgreSQL vs MySQL vs MariaDB - Performance Analysis 2025

Which Database Will Actually Survive Your Production Load?

PostgreSQL
/compare/postgresql/mysql/mariadb/performance-analysis-2025
100%
compare
Recommended

PostgreSQL vs MySQL vs MongoDB vs Cassandra - Which Database Will Ruin Your Weekend Less?

Skip the bullshit. Here's what breaks in production.

PostgreSQL
/compare/postgresql/mysql/mongodb/cassandra/comprehensive-database-comparison
100%
howto
Recommended

How I Migrated Our MySQL Database to PostgreSQL (And Didn't Quit My Job)

Real migration guide from someone who's done this shit 5 times

MySQL
/howto/migrate-legacy-database-mysql-postgresql-2025/beginner-migration-guide
100%
howto
Recommended

Deploy Django with Docker Compose - Complete Production Guide

End the deployment nightmare: From broken containers to bulletproof production deployments that actually work

Django
/howto/deploy-django-docker-compose/complete-production-deployment-guide
82%
tool
Recommended

pgcli - psql That Doesn't Suck

competes with pgcli

pgcli
/tool/pgcli/overview
58%
tool
Recommended

MyCLI - Terminal MySQL Client with Auto-completion and Syntax Highlighting

Finally, a MySQL client that works with you instead of against you.

MyCLI
/tool/mycli/overview
58%
tool
Recommended

SQLite Performance: When It All Goes to Shit

Your database was fast yesterday and slow today. Here's why.

SQLite
/tool/sqlite/performance-optimization
57%
compare
Recommended

PostgreSQL vs MySQL vs MariaDB vs SQLite vs CockroachDB - Pick the Database That Won't Ruin Your Life

compatible with sqlite

sqlite
/compare/postgresql-mysql-mariadb-sqlite-cockroachdb/database-decision-guide
57%
tool
Recommended

SQLite - The Database That Just Works

Zero Configuration, Actually Works

SQLite
/tool/sqlite/overview
57%
tool
Recommended

MySQL HeatWave - Oracle's Answer to the ETL Problem

Combines OLTP and OLAP in one MySQL database. No more data pipeline hell.

Oracle MySQL HeatWave
/tool/oracle-mysql-heatwave/overview
57%
news
Recommended

Oracle Bet $300 Billion on OpenAI Not Going Bankrupt

compatible with OpenAI GPT-5-Codex

OpenAI GPT-5-Codex
/news/2025-09-16/oracle-openai-300b-deal-analysis
57%
tool
Recommended

Oracle GoldenGate - Database Replication That Actually Works

Database replication for enterprises who can afford Oracle's pricing

Oracle GoldenGate
/tool/oracle-goldengate/overview
57%
tool
Recommended

LiteCLI - SQLite CLI That Doesn't Suck

competes with LiteCLI

LiteCLI
/tool/litecli/overview
52%
tool
Recommended

DataGrip - Database IDE That Doesn't Completely Suck

Cross-platform database tool that actually works with multiple databases from one interface

DataGrip
/tool/datagrip/overview
52%
troubleshoot
Recommended

Docker Daemon Won't Start on Windows 11? Here's the Fix

Docker Desktop keeps hanging, crashing, or showing "daemon not running" errors

Docker Desktop
/troubleshoot/docker-daemon-not-running-windows-11/windows-11-daemon-startup-issues
52%
tool
Recommended

Docker 프로덕션 배포할 때 털리지 않는 법

한 번 잘못 설정하면 해커들이 서버 통째로 가져간다

docker
/ko:tool/docker/production-security-guide
52%
integration
Recommended

Connecting ClickHouse to Kafka Without Losing Your Sanity

Three ways to pipe Kafka events into ClickHouse, and what actually breaks in production

ClickHouse
/integration/clickhouse-kafka/production-deployment-guide
52%
tool
Recommended

ClickHouse - Analytics Database That Actually Works

When your PostgreSQL queries take forever and you're tired of waiting

ClickHouse
/tool/clickhouse/overview
52%
pricing
Recommended

Your Snowflake Bill is Out of Control - Here's Why

What you'll actually pay (hint: way more than they tell you)

Snowflake
/pricing/snowflake/cost-optimization-guide
52%
integration
Recommended

dbt + Snowflake + Apache Airflow: Production Orchestration That Actually Works

How to stop burning money on failed pipelines and actually get your data stack working together

dbt (Data Build Tool)
/integration/dbt-snowflake-airflow/production-orchestration
52%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization