A high-performance, zero-dependency SQL query engine built in TypeScript for querying CSV, JSON, TSV, and JSONL files directly from your terminal.
- Multi-Format Support: Query
.csv,.json,.tsv, and.jsonlfiles. - Advanced SQL Syntax:
SELECT DISTINCT,ASaliases, and column prefixes.WHEREwithAND,OR,NOT,LIKE,IN, andIS NULL.- Aggregations:
COUNT,SUM,AVG,MIN,MAX. - Grouping:
GROUP BYandHAVING. - Joins:
INNER JOINandLEFT JOINwithONconditions. - Sorting & Pagination:
ORDER BY (ASC/DESC),LIMIT, andOFFSET. - Arithmetic: Use
+,-,*,/,%in selection and filters.
- CLI Power:
--format [table|json|csv]output options.--output results.csvto save directly to disk.--explainto visualize the query execution plan.
- Zero Runtime Dependencies: Lightweight and fast.
npm install
npm run buildRun queries using ts-node (for development) or node after building.
npx ts-node src/index.ts query "SELECT * FROM data/users.csv"npx ts-node src/index.ts query "SELECT name AS full_name, age FROM data/users.csv WHERE age > 25 AND city LIKE 'N%'"npx ts-node src/index.ts query "SELECT city, COUNT(*) as total, AVG(salary) FROM data/users.csv GROUP BY city HAVING COUNT(*) > 1"npx ts-node src/index.ts query "SELECT u.name, o.product FROM data/users.csv u LEFT JOIN data/orders.csv o ON u.id = o.user_id"# Export to JSON
npx ts-node src/index.ts query "SELECT * FROM data/users.csv" --format json
# Explain query plan
npx ts-node src/index.ts query "SELECT city, SUM(salary) FROM data/users.csv GROUP BY city" --explain
# Save to file
npx ts-node src/index.ts query "SELECT * FROM data/users.csv" --output backup.csv| Clause | Support |
|---|---|
| SELECT | *, col, expr AS alias, DISTINCT, AGG(col) |
| FROM | file.csv, file.json, file.tsv, file.jsonl, (subquery) |
| JOIN | INNER JOIN, LEFT JOIN |
| WHERE | =, !=, <>, <, >, <=, >=, AND, OR, NOT, LIKE, IN, IS NULL |
| GROUP BY | Single or multiple columns |
| HAVING | Filter aggregated results |
| ORDER BY | ASC, DESC (Multiple columns supported) |
| LIMIT | Row count limit |
| OFFSET | Row skip count |
| Operators | +, -, *, /, % |
The project uses Node's native test runner (no external test dependencies like Jest).
npm test- Tokenizer: Scans SQL string into tokens.
- Parser: Recursive descent parser that builds an AST (Abstract Syntax Tree).
- Executor: Walks the AST and applies the data pipeline:
- Load -> Join -> Filter -> Group -> Aggregate -> Project -> Distinct -> Sort -> Slice.
- Formatter: Renders the result as a ASCII table, JSON, or CSV.
MIT