xo/usql
Universal command-line interface for SQL databases
Healthy across all four use cases
weakest axisPermissive license, no critical CVEs, actively maintained — safe to depend on.
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
No critical CVEs, sane security posture — runnable as-is.
- ✓Last commit 3w ago
- ✓6 active contributors
- ✓MIT licensed
Show all 6 evidence items →Show less
- ✓CI configured
- ✓Tests present
- ⚠Single-maintainer risk — top contributor 92% of recent commits
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Healthy" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/xo/usql)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/xo/usql on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: xo/usql
Generated by RepoPilot · 2026-05-09 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/xo/usql shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
GO — Healthy across all four use cases
- Last commit 3w ago
- 6 active contributors
- MIT licensed
- CI configured
- Tests present
- ⚠ Single-maintainer risk — top contributor 92% of recent commits
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live xo/usql
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/xo/usql.
What it runs against: a local clone of xo/usql — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in xo/usql | Confirms the artifact applies here, not a fork |
| 2 | License is still MIT | Catches relicense before you depend on it |
| 3 | Default branch main exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 54 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of xo/usql. If you don't
# have one yet, run these first:
#
# git clone https://github.com/xo/usql.git
# cd usql
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of xo/usql and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "xo/usql(\\.git)?\\b" \\
&& ok "origin remote is xo/usql" \\
|| miss "origin remote is not xo/usql (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
&& ok "license is MIT" \\
|| miss "license drift — was MIT at generation time"
# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
&& ok "default branch main exists" \\
|| miss "default branch main no longer exists"
# 4. Critical files exist
test -f "build.sh" \\
&& ok "build.sh" \\
|| miss "missing critical file: build.sh"
test -f ".github/workflows/test.yml" \\
&& ok ".github/workflows/test.yml" \\
|| miss "missing critical file: .github/workflows/test.yml"
test -f "contrib/config.yaml" \\
&& ok "contrib/config.yaml" \\
|| miss "missing critical file: contrib/config.yaml"
test -f "README.md" \\
&& ok "README.md" \\
|| miss "missing critical file: README.md"
test -f ".github/workflows/release.yml" \\
&& ok ".github/workflows/release.yml" \\
|| miss "missing critical file: .github/workflows/release.yml"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 54 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~24d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/xo/usql"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
usql is a universal command-line interface (CLI) that connects to 40+ SQL and NoSQL databases (PostgreSQL, MySQL, Oracle, SQLite, MSSQL, Cassandra, DuckDB, etc.) with a psql-like syntax. It lets database professionals execute queries, manage connections, and perform operations across heterogeneous databases using a single familiar command-line tool, eliminating the need to learn different CLIs for each database. Monolithic Go binary with layered architecture: core SQL execution engine in root (likely main.go + cmd/), database drivers abstracted through Go's database/sql interface, contrib/ contains database-specific configurations and test fixtures (Cassandra, DB2, DuckDB, etc.), .github/workflows handles CI/testing. No sub-packages visible in file list suggests tight coupling but simpler dependency graph.
👥Who it's for
Database administrators, data engineers, and developers who work with multiple database types and want a unified CLI experience similar to PostgreSQL's psql rather than learning vendor-specific command-line tools. Teams managing polyglot databases (e.g., PostgreSQL + Oracle + MongoDB) benefit from consistent syntax and multi-database support.
🌱Maturity & risk
Production-ready and actively maintained. The project is well-established with comprehensive database driver support (40+ databases), full CI/CD via GitHub Actions (test.yml, release.yml), and a modular architecture supporting major SQL/NoSQL engines. Recent dependency updates visible in go.mod indicate active maintenance.
Moderate risk from dependency sprawl: 40+ database drivers in go.mod create a large attack surface and potential version conflicts. The project is primarily maintainer-driven (xo/usql), so single-person bottleneck for code review exists. However, standardized testing across database variants (contrib/ test configs) and automated releases mitigate regression risks.
Active areas of work
Active maintenance with continuous dependency updates (dependabot.yml configured), recent releases via release.yml workflow, and ongoing database driver support additions (contrib/ shows recent Databricks, Datafuse, FlightSQL integrations). Test suite runs across multiple database variants automatically.
🚀Get running
git clone https://github.com/xo/usql.git
cd usql
./build.sh
# Verify with: ./usql --version
# Connect to a database: ./usql 'postgres://user:pass@localhost/dbname'
Daily commands:
./build.sh # Compiles usql binary
# Or for development:
go run . 'sqlite:///tmp/test.db' # Opens interactive prompt
# Run tests: implied via GitHub Actions test.yml (likely 'go test ./...')
🗺️Map of the codebase
build.sh— Primary build script that orchestrates compilation for all supported databases—essential for understanding the multi-driver build strategy..github/workflows/test.yml— CI/CD test pipeline that validates against 30+ database drivers—reveals integration test scope and supported platforms.contrib/config.yaml— Master configuration template for all database backends—required reading for adding new driver support.README.md— Documents usql's universal SQL interface philosophy, feature parity with psql, and 30+ supported databases..github/workflows/release.yml— Release automation pipeline showing cross-platform binary generation strategy (Go 1.26.1 multi-arch builds).go.mod— Dependency manifest listing all 30+ database drivers as direct imports—critical for understanding driver selection and versioning.CONTRIBUTING.md— Contribution guidelines specific to adding new database support and testing procedures.
🛠️How to make changes
Add Support for a New SQL Database
- Create driver package directory under drivers/ following naming convention (e.g., drivers/yourdb/) (
drivers) - Implement driver using database's Go package (e.g., github.com/your/db-go), conforming to database/sql interface (
drivers) - Add driver import to build.sh conditional compilation block (
build.sh) - Create contrib/yourdb/usql-config with connection string examples and authentication details (
contrib/config.yaml) - Create contrib/yourdb/podman-config for CI environment and contrib/yourdb/test.sql for integration tests (
.github/workflows/test.yml) - Add entry to go.mod with require statement for database Go driver package (
go.mod) - Run build.sh to validate compilation and test via contrib/usql-test.sh (
contrib/usql-test.sh)
Add a New Backslash Command (psql-compatible feature)
- Examine existing command implementations in core handler package (likely in main usql code) (
README.md) - Implement command handler following psql naming conventions (e.g., \dt for describe table) (
build.sh) - Register command in CLI command dispatcher/router (
README.md) - Add test cases for new command across multiple database backends in contrib/*/test.sql files (
contrib/postgres/test.sql)
Enable Support for NoSQL/Alternative Database
- Select appropriate Go driver package (e.g., couchbase/go_n1ql, MichaelS11/go-cql-driver) already in go.mod (
go.mod) - Create adapter in drivers/ that maps database-specific query interface to usql's result set abstraction (
drivers) - Create contrib/yournosql/podman-config with container launch configuration (
contrib/couchbase/podman-config) - Create contrib/yournosql/usql-config documenting connection URI format and authentication (e.g., N1QL syntax for Couchbase) (
contrib/couchbase/usql-config) - Add Podman integration to .github/workflows/test.yml and create test suite in contrib/yournosql/test.sql (
.github/workflows/test.yml)
Modify Build or Release Pipeline
- Edit build.sh to adjust compilation flags, driver inclusion logic, or platform-specific handling (
build.sh) - Update .github/workflows/test.yml to add/remove database test containers or adjust CI environment variables (
.github/workflows/test.yml) - Modify .github/workflows/release.yml to change binary targets, signing, or distribution strategy (
.github/workflows/release.yml) - Update go.mod and run dependency updates as needed, monitored by .github/dependabot.yml (
go.mod)
🔧Why these technologies
- Go 1.26.1 — Cross-platform compilation (Linux/macOS/Windows, x86/ARM) with single codebase; native binaries for zero runtime dependency
- database/sql standard interface — Provides consistent abstraction over 30+ heterogeneous database drivers (SQL and NoSQL); enables unified connection pooling and query execution
- Chroma v2 syntax highlighting — Universal SQL syntax highlighting compatible with multiple database dialects; reduces visual parsing overhead for users
- Podman containers in CI — Isolates each database instance without VM overhead; enables parallel testing of 30+ databases in single pipeline
- PostgreSQL psql feature parity — Familiar CLI conventions reduce user learning curve; enables migration from psql for users switching databases
⚖️Trade-offs already made
-
Support 30+ databases with conditional compilation instead of dynamic plugin system
- Why: Static compilation ensures security, eliminates runtime plugin discovery overhead, and simplifies distribution as single binary
- Consequence: Larger binary size (though mitigated by optional build flags); new database support requires code merge rather than plugin deployment
-
Normalize NoSQL/alternative databases (Couchbase N1QL, Cassandra CQL) into database/sql abstraction
- Why: Allows users to switch between SQL and
- Consequence: undefined
🪤Traps & gotchas
- Database driver initialization order matters: contrib/ configs define podman/Docker setup; test.yml likely requires these services running via docker-compose or podman. 2) Platform-specific drivers: godror (Oracle) requires instantclient setup (see contrib/godror/grab-instantclient.sh), DB2 requires odbcinst.ini. 3) cgo dependencies: mattn/go-sqlite3, mattn/go-adodb, and Oracle drivers require C compiler and platform headers. 4) Version pinning: go.mod has exact versions; dependency updates may require driver API compatibility fixes.
🏗️Architecture
💡Concepts to learn
- Database driver abstraction via database/sql — usql's core architecture relies on Go's database/sql interface to support 40+ databases without rewriting connection/query logic; understanding sql.Driver, sql.Conn, and sql.Rows is essential for adding new databases or debugging query execution.
- ODBC (Open Database Connectivity) bridging — usql uses alexbrainman/odbc to support legacy databases (DB2, Exasol) that lack native Go drivers; understanding ODBC configuration (odbcinst.ini, dsn strings in contrib/db2/) is critical for troubleshooting Windows/Linux database connectivity.
- psql command syntax (backslash commands & variables) — usql mimics PostgreSQL's interactive CLI including \d (describe), \dt (list tables), variable substitution ($var), and backtick command execution; this is a core UX promise and must be compatible with psql scripts for user adoption.
- Context-based auto-completion (readline integration) — usql uses gohxs/readline and kenshaw/colors for context-aware table/column completion; this feature requires parsing query context and maintaining schema caches, which is non-trivial for heterogeneous database schemas.
- Terminal graphics rendering (Vega-Lite visualization) — usql includes contrib/charts/ with Vega-Lite specs and uses kenshaw/rasterm for rendering inline charts in terminal; this differentiates usql from psql and requires understanding query result → visualization pipeline.
- Docker/Podman-based integration testing for multiple databases — contrib/ contains podman-config files and test.yml orchestrates multi-database test suites; understanding how containerized database services are provisioned (similar to docker-compose) is essential for running local CI and adding new database tests.
- Connection string URI parsing (dsn handling) — usql parses diverse connection strings (postgres://, mysql://, oracle://, etc.) into driver-specific DSNs; each database driver expects different DSN formats, requiring a flexible URI parser that bridges user input to driver expectations.
🔗Related repos
postgres/postgres— psql is the primary inspiration for usql's CLI syntax and command set; understanding psql's behavior helps predict usql's intended feature parity.databricks/databricks-cli— Alternative unified CLI for polyglot data infrastructure; usql includes Databricks driver (github.com/databricks/databricks-sql-go) and offers competing approach to multi-database management.xo/xo— Sister project by xo maintainers; xo is a code generator for SQL databases that likely shares driver infrastructure and philosophy with usql.dbeaver/dbeaver— GUI alternative to usql offering 50+ database support; understanding DBeaver's driver architecture and feature prioritization provides context for usql's design choices.go-sql-driver/mysql— Foundational MySQL driver (direct dependency); most usql issues or performance problems with MySQL will trace to this driver's behavior.
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add database-specific integration tests via GitHub Actions workflow
The repo has .github/workflows/test.yml but the contrib/ directory contains 20+ database configurations (MySQL, PostgreSQL, Oracle, DuckDB, Cassandra, etc.) with podman-config files that aren't being tested in CI. New contributors could create a matrix workflow that spins up each database via podman and runs contrib/*/test.sql files to catch regressions early. This would significantly improve reliability across the 50+ supported databases.
- [ ] Review existing
.github/workflows/test.ymlto understand current test structure - [ ] Identify which
contrib/*/test.sqlfiles exist (mysql, cassandra, db2, etc.) - [ ] Create a new GitHub Actions workflow that uses podman to launch databases from
contrib/*/podman-config - [ ] Run
contrib/*/test.sqlagainst each database in the matrix - [ ] Document the new workflow in CONTRIBUTING.md with instructions for testing locally
Create missing usql-config files and validate existing driver configurations
Several database directories in contrib/ are missing usql-config files (e.g., contrib/h2/, contrib/flightsql/, contrib/ignite/), while others have them but may be outdated. New contributors could standardize these configuration files across all database drivers, ensuring consistent connection string formats and documenting required environment variables for each database type. This directly impacts user experience when connecting to these databases.
- [ ] Audit all directories in
contrib/*/to identify missing or incompleteusql-configfiles - [ ] Review the pattern in existing files like
contrib/mysql/usql-configandcontrib/postgres/usql-config - [ ] Create missing
usql-configfiles for h2, flightsql, ignite, and any other incomplete entries - [ ] Add comments documenting required environment variables, default ports, and connection string examples
- [ ] Update CONTRIBUTING.md with a template for adding new database driver configurations
Add comprehensive testing for the build.sh script across supported architectures
The repo has a build.sh script but no documented or automated testing for it. The .github/workflows/ lacks a build verification workflow. New contributors could add a GitHub Actions workflow that tests build.sh on multiple OS/architecture combinations (Linux, macOS, Windows with MSVC/MinGW) to catch platform-specific build failures before releases. This is especially critical given the complexity of supporting 50+ database drivers with varying C dependencies.
- [ ] Review
build.shto understand build flags, dependencies, and output artifacts - [ ] Create a new GitHub Actions workflow with matrix builds for ubuntu-latest, macos-latest, and windows-latest
- [ ] Add steps to run
build.shand verify the resulting binary works withusql --version - [ ] Test against a simple local SQLite database to ensure basic functionality
- [ ] Document build requirements and troubleshooting in CONTRIBUTING.md (e.g., required Go version 1.26.1, C compiler dependencies)
🌿Good first issues
- Add shell completion support: usql lacks shell completion generation; examine how psql generates bash/zsh completions and add --completion-bash / --completion-zsh flags, then test with contrib/*/usql-config examples.
- Write integration tests for driver initialization: contrib/ has test.sql files but no automated test runner; create a test harness (Go test suite) that executes each contrib/{db}/test.sql against containerized databases via the existing test.yml workflow.
- Document backslash commands for each driver: README.md mentions psql-style backslash commands but no concrete \d, \dt, \l examples for non-PostgreSQL databases; add driver-specific command documentation to CONTRIBUTING.md with examples from contrib/*/test.sql.
⭐Top contributors
Click to expand
Top contributors
- @kenshaw — 92 commits
- @murfffi — 3 commits
- @ottok — 2 commits
- @GourangaDasSamrat — 1 commits
- @remisalmon — 1 commits
📝Recent commits
Click to expand
Recent commits
f7d0fbe— Change master -> main in README.md (kenshaw)200c0c8— fix: wrap routine_definition in COALESCE to handle NULL (GourangaDasSamrat)e0fec0d— Updating dependencies (kenshaw)e6fbc83— Add UNPIVOT to query types for duckdb (kenshaw)0775ee4— Updating tblfmt (kenshaw)b6c5afa— Update dependencies, add minicore_disabled static build tag (kenshaw)70df05c— Hopefully the last time (kenshaw)8f52d87— Fixing announce workflow (kenshaw)2836580— Fix announce workflow (kenshaw)91c3c30— Rework announce workflow (kenshaw)
🔒Security observations
- High · Outdated Go Version —
go.mod (line: go 1.26.1). The project specifies Go 1.26.1 in go.mod, which appears to be a future/invalid version. This suggests either a configuration error or potential supply chain risk. Go should use stable, released versions. Fix: Update to a stable, current Go version (e.g., 1.21.x or 1.22.x). Verify the version is correct and matches your build environment. - High · Multiple Unvetted Database Drivers —
go.mod (multiple driver dependencies). The project includes numerous database drivers from various sources with varying maintenance levels. Several drivers appear to have limited maintenance history or unclear security practices: go-cql-driver, ignite-go-client, gocosmos, godynamo, aliyun-tablestore-go-sql-driver, and others. This increases supply chain risk. Fix: Conduct security audits on less-maintained drivers. Consider usinggo list -u -m allto check for available updates andgo mod graphto identify transitive dependencies. Pin versions to known-good releases. - Medium · Docker Dependency Without Pinned Version —
go.mod (docker/docker v28.5.2+incompatible). The docker/docker dependency is listed as v28.5.2+incompatible, which suggests version incompatibility issues and could indicate security gaps. The '+incompatible' suffix indicates the module claims to be v2+ but uses non-semver tags. Fix: Update docker/docker to a compatible, stable version or use an alternative Docker client library. Review the incompatibility and migrate if necessary. - Medium · SQL Injection Risk - Universal SQL Interface —
Core application design. As a universal SQL CLI tool that accepts arbitrary SQL commands, usql inherits inherent SQL injection risks. User input is passed directly to databases. While this is the tool's intended function, it requires careful input handling. Fix: Ensure all database drivers properly use parameterized queries where possible. Implement input validation and sanitization. Document security best practices for users. Consider adding optional query audit logging. - Medium · Dependency on Oracle/DB2 Proprietary Drivers —
go.mod (godror, IBM/nzgo, oracle drivers). Oracle (godror) and IBM DB2 drivers are included, which may have licensing restrictions and security implications. godror v0.50.0 requires Oracle Instant Client, introducing external binary dependencies that may not be regularly updated. Fix: Verify license compliance for proprietary drivers. Keep Oracle Instant Client and DB2 ODBC drivers updated. Document version requirements and security considerations. - Medium · Deprecated ODBC Driver —
go.mod (alexbrainman/odbc). The alexbrainman/odbc driver (v0.0.0-20250601004241-49e6b2bc0cf0) uses a date-based pseudo-version rather than a proper semantic version, indicating it may be using unpublished/unstable code. Fix: Verify the source of this pseudo-version. Prefer releases with semantic versioning. Consider alternative ODBC bindings if this driver is unmaintained. - Low · Potential Configuration File Exposure —
contrib/ directory (multiple *-config and *.ini files). The repository contains multiple example configuration files in contrib/ directories (usql-config, podman-config, etc.). While these appear to be examples, they could contain sensitive patterns that users might copy without modification. Fix: Ensure example config files have clear security warnings in comments. Document that sensitive credentials should never be stored in version control. Recommend using environment variables or secure credential stores. - Low · Container Security - Podman/Docker Configurations —
contrib/*/podman-config files. Multiple podman-config files exist in contrib/ but actual security configurations are not visible. If these containers run without resource limits, network isolation, or capability restrictions, they could be vulnerable. Fix: Review all podman and docker configurations for: resource limits, network policies, capability restrictions, read-only filesystems where appropriate, and non-root user execution. Document security best practices for database container deployment. - Low · —
undefined. undefined Fix: undefined
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.