Create a MySQL table from any CSV using javascript.
git clone https://github.com/clementherve/csv2sql.git
pnpm i
pnpm build:watch
pnpm tests
# or
pnpm run tests:watch
Run the following command and the SQL file should be generated.
node ./out/src/cli.js <csv file>
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');