trdsql
Execute SQL queries on CSV, JSON, LTSV, YAML, and TBLN files
TLDR
SYNOPSIS
trdsql [-i format] [-o format] [options] query
DESCRIPTION
trdsql executes SQL queries directly against structured data files such as CSV, JSON, LTSV, YAML, and TBLN without importing them into a database first. File names are used as table names in SQL statements, making it straightforward to filter, aggregate, and transform data using familiar SQL syntax.The tool supports joining data across multiple files, enabling relational queries between different data sources in a single command. Input and output formats can be specified independently, allowing conversion between formats as a side effect of querying.Under the hood, trdsql uses SQLite as the default query engine but can also connect to PostgreSQL and MySQL for more advanced SQL features. Headers in CSV files can be used as column names with the -ih flag.
PARAMETERS
-i FORMAT
Input format (csv, json, ltsv, yaml, tbln).-o FORMAT
Output format (csv, json, jsonl, ltsv, raw, md, at, vf, tbln).-ih
Input has header row.-oh
Output with header.-id DELIM
Input delimiter character.-od DELIM
Output delimiter character.-driver DRIVER
Database driver (sqlite3, postgres, mysql).-dsn DSN
Database connection string.-debug
Show debug output.
CAVEATS
Go-based tool. Large files are loaded into memory. SQL knowledge required. Default database engine is SQLite.
HISTORY
trdsql was created to execute SQL queries against various structured data formats like CSV and JSON.
