Run SQL queries on Data files with TrdSQL
Trdsql is a command-line python application that execute SQL queries on flat data files like CSV, TSV, LTSV, TBLN and JSON files. It also allows exporting the outputs in several formats.
The application is written in Go language which known for speed and performance.
The reason why did we choose to write about trdSQL
is that we used it in some tasks. It is proven to be a useful and reliable tool.
The trdsql
supports both MySQL and PostgreSQL queries. It also can execute SQL queries from .sql files.
trdsql -q test.sql
The Trdsql tool is an advanced alternative for "q" which built with Python, and "textql" which allow executing SQL queries against structured CSV and TSV files. It supports more files format, different output options and process compressed and multiple files.
Highlights
- Supports multiple file formats
- Supports multiple output formats
- Multiple file inputs (not possible to mix different formats)
- Process compressed files: gzip, bz2, zstd, lz4, xz
- Compress output files
- Join table
- Join
csv
files - Switch query driver (MySQL and PostgreSQL)
- Configuration file
config.json
- It Can be used as Go language library.
- Process large files
Supported file formats
- CSV (Comma Separated Values)
- TSV (Tab Separated Values)
- LTSV (Labeled Tab-separated Values)
- JSON
- JSONL
- TBLN
Output formats
- Raw output
- ASCII Table output
- Markdown output
- The vertical format output
Install
The trdsql
has different installation options
- Building the source with Go (requires go 1.13 or higher)
- Download and install binary releases for Linux, Windows and macOS from here.
- Use it within Docker container
docker pull noborus/trdsql
License
The library is released as an open-source package under MIT license.