| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A command-line tool written in Rust that infers SQL data types from a CSV file and generates a CREATE TABLE SQL DDL statement. It aims to determine the strictest possible SQL type for each column that can accommodate all its values.
Ensure you have Rust and Cargo installed. If not, follow the instructions at rust-lang.org.
Clone the repository:
git clone <your-repository-url>
cd csv-sql-inferenceBuild the project:
cargo build --releaseThe executable will be located at target/release/csv_sql_inference.
Run the tool from the command line, providing the path to your CSV file:
./target/release/csv_sql_inference <path_to_csv_file>or, if you've added the target/release directory to your path:
csv_sql_inference <path_to_csv_file>the generated create table sql statement will be printed to standard output.
given a csv file named products.csv:
id,product_name,quantity,price,entry_date,last_updated
1,apple,10,0.50,2023-01-01,2024-05-01 10:00:00
2,banana,,1.20,2023-01-02,2024-05-02 11:30:15
3,orange,5,0.75,invalid-date,2024-05-03 09:00:00
4,grape,20000000000,0.05,2023-03-10,2024-05-04 14:20:05running the command:
./target/release/csv_sql_inference products.csvwould produce output similar to this (exact varchar lengths depend on the longest string in each respective column):
CREATE TABLE "products" (
"id" integer,
"product_name" varchar(6),
"quantity" bigint,
"price" float,
"entry_date" varchar(12),
"last_updated" datetime
);explanation of example output:
to run the unit and integration tests:
cargo test| Back | FazBrowse Home | New Git URL |