| Crates.io | table-to-csv |
| lib.rs | table-to-csv |
| version | 0.4.0 |
| created_at | 2025-10-02 13:36:30.031174+00 |
| updated_at | 2025-10-02 13:36:30.031174+00 |
| description | Parsley CSV is a command-line tool that converts SQL database dumps to CSV files. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1864393 |
| size | 44,515 |
A Rust command-line tool that converts SQL database dumps to CSV files. Table to CSV parses SQL files containing CREATE TABLE and INSERT statements and extracts the data into separate CSV files for each table.
CREATE TABLE statementsINSERT statements and converts to CSV format--date-filter optionreplace()The easiest way to install Table to CSV is via cargo:
cargo install table-to-csv
This will install the table-to-csv binary to your Cargo bin directory (typically ~/.cargo/bin/).
cargo build --release
The executable will be created at target/release/table-to-csv.
table-to-csv <sql_file>
table-to-csv <sql_file> --date-filter <column_name> <start_date> [end_date]
Or if built from source:
./target/release/table-to-csv <sql_file> [--date-filter <column_name> <start_date> [end_date]]
Or using Cargo (when developing):
cargo run <sql_file> [-- --date-filter <column_name> <start_date> [end_date]]
# Using the installed binary (after cargo install table-to-csv)
table-to-csv database.sql
# Convert a database dump to CSV files (when developing)
cargo run database.sql
# Using the compiled binary from source
./target/release/table-to-csv test.sql
# Filter by date range (column name: createdAt, from 2024-01-01 to 2024-12-31)
table-to-csv database.sql --date-filter createdAt 2024-01-01 2024-12-31
# Filter from a start date to today (end date defaults to today)
table-to-csv database.sql --date-filter date 2023-06-15
# Using Cargo with date filter
cargo run database.sql -- --date-filter createdAt 2024-01-01
Date Format: YYYY-MM-DD
Note: If end_date is not provided, it defaults to today's date
CREATE TABLE statements to extract table names and column definitionsINSERT statements for each table and extracts the values'' for single quotes, "" for double quotes)replace() for JSON dataGiven a SQL file like test.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE
);
INSERT INTO users VALUES(1, 'Alice Smith', 'alice@example.com');
INSERT INTO users VALUES(2, 'Bob Johnson', 'bob@example.com');
Table to CSV will generate users.csv:
id,name,email
1,Alice Smith,alice@example.com
2,Bob Johnson,bob@example.com
CREATE TABLE statements with various column typesINSERT INTO ... VALUES statementsreplace() function callscsv - CSV file reading and writingregex - Regular expression pattern matchinganyhow - Error handlingrayon - Parallel processing for improved performancechrono - Date and time parsing for date filteringRun the test suite:
cargo test
The project includes unit tests for:
The tool provides clear error messages for common issues:
This project is open source. Please check the license file for details.
Contributions are welcome! Please feel free to submit issues and pull requests.
When processing a SQL file, Table to CSV will output:
Processing SQL file: database.sql
Found table: CallLogs with 9 columns
Found table: CallSession with 9 columns
Found table: d1_migrations with 3 columns
Created calllogs.csv with 35 rows
Created callsession.csv with 89 rows
Created d1_migrations.csv with 3 rows
Conversion complete!
Generated CSV files:
- calllogs.csv
- callsession.csv
- d1_migrations.csv
To view the CSV files, you can use:
cat calllogs.csv | head -5
cat callsession.csv | head -5
Or open them in a spreadsheet application.
When using the date filter feature:
Date filter enabled:
Column: createdAt
Start date: 2024-01-01
End date: 2024-12-31
Processing SQL file: database.sql
Found table: CallLogs with 9 columns
Found table: CallSession with 9 columns
Found table: d1_migrations with 3 columns
Created calllogs.csv with 15 rows
Created callsession.csv with 42 rows
Warning: No rows remain for table 'd1_migrations' after filtering - skipping
Conversion complete!
Generated CSV files:
- calllogs.csv
- callsession.csv
To view the CSV files, you can use:
cat calllogs.csv | head -5
cat callsession.csv | head -5
Or open them in a spreadsheet application.