Repolode
neilotoole

neilotoole/sq

A command-line tool that queries and joins SQL databases and files like CSV, Excel and JSON with jq-style or SQL syntax.

Stars
2,573
Forks
43
Open issues
87
Last commit
22 hours ago

What is it?

sq is a command-line tool that treats SQL databases and document files such as CSV, TSV, JSON, and Excel XLSX as queryable data sources. Each source is added under a handle, and commands run against it either with a jq-style query language or with native SQL.

sq can join data across sources, for example a CSV file with a Postgres table or a MySQL table with an Excel worksheet. Query results can be written to formats including JSON, CSV, XLSX, HTML, Markdown and XML, or inserted directly into a database table. It also inspects source structure (tables, columns, sizes), diffs schemas and row data, and copies, truncates or drops tables.

The project lists drivers for SQLite, DuckDB, PostgreSQL, SQL Server, MySQL, ClickHouse, Oracle and rqlite, and is installable via Homebrew, Scoop, a shell script, Go, or Docker.

Key features

  • 01Query data sources with jq-style syntax or native SQL.
  • 02Join tables across different sources, such as CSV with Postgres.
  • 03Export results to JSON, CSV, XLSX, HTML, Markdown, XML and more.
  • 04Inspect source metadata and diff schemas or row data.
  • 05Copy, truncate and drop tables in SQL database sources.

Use cases

  • Joining an Excel sheet or CSV export with a production database table for ad hoc analysis.
  • Inspecting an unfamiliar SQLite or Postgres database from the terminal.
  • Converting a spreadsheet or CSV into JSON or another format in a shell pipeline.
  • Comparing schemas or data between two database environments.

Quick start

  1. 1

    Install on macOS with Homebrew

    brew install sq
  2. 2

    Install on Windows with Scoop (add the bucket first)

    scoop bucket add sq https://github.com/neilotoole/sq
  3. 3

    Install with Go (requires the SQLite build tags)

    go install -tags "sqlite_vtable sqlite_stat4 sqlite_fts5 sqlite_introspect sqlite_json sqlite_math_functions" github.com/neilotoole/sq@latest
  4. 4

    Run the official install script for Linux from the README

Things to know

  • The Linux install relies on a downloaded shell script, and the Go install reports version v0.0.0-dev unless built from a clone with make install.

Topics

FAQ

What is sq?
A command-line tool that queries and joins SQL databases and files like CSV, Excel and JSON with jq-style or SQL syntax. sq is a command-line tool that treats SQL databases and document files such as CSV, TSV, JSON, and Excel XLSX as queryable data sources. Each source is added under a handle, and commands run against it either with a jq-style query language or with native SQL.
Is sq free to use? What license does it have?
sq is open source under the MIT license. Check the license terms before using it in commercial products.
Is sq still maintained?
Actively maintained. The last commit to sq was on Oct 21, 2026.
What can I use sq for?
Joining an Excel sheet or CSV export with a production database table for ad hoc analysis. Inspecting an unfamiliar SQLite or Postgres database from the terminal. Converting a spreadsheet or CSV into JSON or another format in a shell pipeline. Comparing schemas or data between two database environments.
How do I install sq?
Install on macOS with Homebrew: brew install sq Install on Windows with Scoop (add the bucket first): scoop bucket add sq https://github.com/neilotoole/sq Install with Go (requires the SQLite build tags): go install -tags "sqlite_vtable sqlite_stat4 sqlite_fts5 sqlite_introspect sqlite_json sqlite_math_functions" github.com/neilotoole/sq@latest Run the official install script for Linux from the README
Where can I get sq?
The source code and installation instructions are on GitHub: https://github.com/neilotoole/sq

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects