explaingit

dinedal/textql

9,115GoAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A command-line tool that runs SQL queries directly on CSV and TSV files without importing them into a database, using an in-memory SQLite engine behind the scenes.

Mindmap

mindmap
  root((textql))
    What it does
      SQL on CSV files
      In-memory SQLite
      Unix pipe support
    Features
      Auto type detection
      Multi-file loading
      Pretty print output
    Use Cases
      Filter rows
      Join data files
      Aggregate and group
    Setup
      Homebrew one line
      Docker or Go build
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Filter and group rows in a CSV file using SQL without opening Excel or a database tool.

USE CASE 2

Join two CSV files together and query them as if they were separate database tables.

USE CASE 3

Chain textql into Unix pipelines to process piped data from other command-line tools with SQL.

Tech stack

GoSQLite

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

textql is a command-line tool that lets you run SQL queries directly against CSV and TSV files, without first importing them into a database. If you have a spreadsheet exported as a CSV and want to filter rows, group data, or join two files together, you can write a SQL statement and feed the files straight to textql rather than opening a database tool or writing a custom script. The tool loads your files into an in-memory SQLite database behind the scenes, runs your query, and prints the results. Because everything stays in memory by default, there is no database file left behind when you are done, unless you specifically ask it to save one. It also accepts data piped in from other command-line tools, which lets you chain it into standard Unix workflows. Several quality-of-life features are included. Numbers and common date formats are automatically detected, so you rarely need to cast columns manually. A shorthand SQL syntax lets you drop the SELECT and FROM keywords for simple queries. You can load multiple files or entire directories at once, and join across them as if they were separate tables. Output can go to stdout or a file, with options for the delimiter, pretty-printing, and whether to include a header row. Installation on a Mac is one line with Homebrew. It can also be built from source using Go, or run inside Docker. An optional extension library adds statistical functions like standard deviation, median, and quartiles if you need more than what SQLite provides by default. The project is written in Go and released under the MIT license. It is a practical shortcut for anyone who regularly deals with structured text files and wants to ask questions of the data without standing up a full database.

Copy-paste prompts

Prompt 1
Using textql, write a SQL query to find the top 10 rows in sales.csv sorted by the 'amount' column and grouped by 'region'.
Prompt 2
How do I join two CSV files with textql on a shared column and write the result to a new file?
Prompt 3
Show me how to use textql's shorthand syntax to filter a CSV without writing the SELECT and FROM keywords.
Prompt 4
How do I pipe output from another Unix command into textql and run a SQL query on it?
Prompt 5
How do I load an entire directory of CSV files into textql and query across all of them at once?
Open on GitHub → Explain another repo

← dinedal on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.