Skip to content

v0.4.0

Choose a tag to compare

@SeanningTatum SeanningTatum released this 02 Oct 13:48
· 2 commits to main since this release

Full Changelog: https://github.com/SeanningTatum/table-to-csv/commits/v0.4.0

Table to CSV v0.4.0

A fast and robust command-line tool for converting SQL database dumps to CSV files, built with Rust.

🎯 Overview

Table to CSV parses SQL files containing CREATE TABLE and INSERT statements and extracts data into separate CSV files for each table. Perfect for data migration, analysis, or exporting database dumps to spreadsheet-friendly formats.

✨ Features

  • SQL Parsing: Automatically detects table schemas from CREATE TABLE statements
  • Data Extraction: Extracts data from INSERT statements and converts to CSV format
  • Multiple Tables: Handles databases with multiple tables, creating separate CSV files for each
  • Date Filtering: Filter rows by date range using the --date-filter option
  • Parallel Processing: Fast multi-threaded CSV generation using Rayon
  • Robust Value Parsing: Properly handles quoted strings, escaped characters, and SQL functions like replace()
  • Flexible Date Formats: Supports ISO 8601, various datetime formats, and Unix timestamps
  • Error Handling: Comprehensive error handling with helpful error messages
  • Cross-Platform: Works seamlessly on Windows, macOS, and Linux

📦 Installation

cargo install table-to-csv

🚀 Quick Start

Basic Usage

table-to-csv database.sql

With Date Filtering

# Filter by date range
table-to-csv database.sql --date-filter createdAt 2024-01-01 2024-12-31

# Filter from start date to today
table-to-csv database.sql --date-filter date 2024-01-01

📝 Example

Input (database.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');

Output (users.csv):

id,name,email
1,Alice Smith,alice@example.com
2,Bob Johnson,bob@example.com

🔧 Technical Details

  • Language: Rust (Edition 2024)
  • Performance: Parallel processing with Rayon for optimal speed
  • Date Parsing: Powered by Chrono, supporting multiple date formats and timezones
  • CSV Generation: Uses the csv crate for standards-compliant output

🛠️ Supported SQL Features

  • CREATE TABLE statements with various column types
  • INSERT INTO ... VALUES statements
  • Single and double-quoted string values
  • Escaped quotes in string values
  • SQL replace() function calls
  • Multi-line table definitions
  • Foreign key constraints (ignored during parsing)
  • Date/timestamp columns for filtering

📊 What's New in v0.4.0

  • Project renamed from "Parsley CSV" to "Table to CSV" for better clarity
  • Enhanced metadata with keywords and author information
  • Comprehensive integration tests
  • Improved documentation and examples
  • Refined package structure for crates.io publication

🧪 Testing

Run the test suite:

cargo test

📄 License

MIT

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests on GitHub.

🙏 Acknowledgments

Built with:

  • csv - CSV file reading and writing
  • regex - Pattern matching
  • anyhow - Error handling
  • rayon - Parallel processing
  • chrono - Date and time handling

Installation: cargo install table-to-csv
Repository: https://github.com/SeanningTatum/table-to-csv/
Author: Sean Urgel (developer@seanurgel.dev)