0.0.3-alpha • Published 1 year ago

@clement-herve/csv-to-sql v0.0.3-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

CodeQL Jest

CSV-TO-SQL

Create a MySQL table from any CSV using javascript.

Setup

    git clone https://github.com/clementherve/csv2sql.git
    pnpm i
    pnpm build:watch

Testing

    pnpm tests
    # or
    pnpm run tests:watch

Usage

Run the following command and the SQL file should be generated.

    node ./out/src/cli.js <csv file>

Example

The file ./example/example.csv

A; B; C; D
0; 1; 2; hoy
; 1; 3; hoy
2; 2; 5; h'ay

will be transformed to

drop table if exists `example`;
create table if not exists `example` (
	`A` int unique,
	`B` int not null,
	`C` int unique not null,
	`D` text not null
);
insert into `example`
	(`A`, `B`, `C`, `D`)
 values
	(0, 1, 2, 'hoy'),
	(null, 1, 3, 'hoy'),
	(2, 2, 5, 'h\'ay');
0.0.2-alpha

1 year ago

0.0.3-alpha

1 year ago

0.0.1-alpha

1 year ago