Installing the command-line executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install csv-sql
It will make the csv-sql command available in your PATH if you've allowed the PATH to be modified when installing Rust . cargo uninstall csv-sql uninstalls.
Back to the crate overview .
Readme
CSV-SQL
CSV-SQL will generate SQL table creation statements from CSV files, currently with TEXT data types only.
CSV-SQL outputs to stdout. You can redirect the output to a file.
Usage
Generate SQL table creation statements from CSV files
The name of the CSV file will be used as the name of the table.
csv-sql [ FILE_PATHS] ...
Generate only the schema without inserting data
csv-sql -- schema-only [ FILE_PATHS] ...
Add a serial primary key
csv-sql -- primary-key= smallint [ FILE_PATHS] ...
csv-sql -- primary-key= integer [ FILE_PATHS] ...
csv-sql -- primary-key= bigint [ FILE_PATHS] ...
Merge multiple tables into one
csv-sql -- merge [ FILE_PATHS] ...
Redirect output to a file
csv-sql [ FILE_PATHS] ... > output.sql
See all options
csv-sql -- help
Development
Use just for easy development.
See all available commands
just - l
Build and run
just dev ~ /Dir/file.csv
just dev " --schema-only ~/Dir/file.csv ~/Dir/file2.csv ~/Dir/file3.csv"
Clear all *.sql files in current directory
just clear
TODO