Skip to content

Repository files navigation

CodeQLJest

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

droptable if exists `example`;
createtableif not exists `example` (
`A`int unique,
`B`intnot null,
`C`int unique not null,
`D`textnot null
);
insert into`example`
(`A`, `B`, `C`, `D`)
values
(0, 1, 2, 'hoy'),
(null, 1, 3, 'hoy'),
(2, 2, 5, 'h\'ay');

About

Create a SQL table from CSV using Node.js script

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages