1 unstable release
Uses new Rust 2024
| 0.1.0 | Dec 24, 2025 |
|---|
#891 in Text processing
35KB
840 lines
mdsql
SQL queries for markdown tables.
Warning: This is an experimental program that modifies files in-place. Always use version control (git) or back up your markdown files before running INSERT or DELETE operations.
Install
cargo install --path .
Usage
# List tables in a file
mdsql tables data.md
# Query first table
mdsql query "SELECT * FROM 0" data.md
# Filter and sort
mdsql query "SELECT name, score FROM 0 WHERE score > 50 ORDER BY score DESC" data.md
# Output as JSON
mdsql query --format json "SELECT * FROM 0" data.md
# Insert a row
mdsql insert "INSERT INTO 0 (name, age, city) VALUES ('Alice', '30', 'NYC')" data.md
# Delete rows
mdsql delete "DELETE FROM 0 WHERE name = 'Alice'" data.md
Supported SQL
SELECTwith column filtering and*WHEREwith=,!=,<,>,<=,>=,AND,ORORDER BY(ASC/DESC)LIMITINSERT INTO ... VALUESDELETE FROM ... WHERE
Tables are referenced by 0-based index: FROM 0, INTO 0, etc.
Output Formats
columns(default) - Column-aligned likedf -h, unix-friendlymarkdown- Markdown tablecsv- Comma-separated valuesjson- JSON array of objectstsv- Tab-separated values
Roadmap
- Split into
mdsqllibrary crate andmdsql-clibinary crate UPDATE ... SET ... WHERE- Aggregate functions (
SUM,COUNT,AVG,MIN,MAX) GROUP BY- Infer table names from preceding markdown headers
Dependencies
~9–14MB
~297K SLoC