json2mysql
A tool to load a JSON/JS object file to Mysql.
Install
npm i json2mysql
Usage
const dbconfig = {}const jm = jmjm
Methods
load
: this will disable foreign key, remove table rows , then load json and enable foreign keyreplace
: this will replace table rows with json file, by comparing table id with array index
Test
docker-compose up -d
will create database container- create a test table in your database:
( `id` mediumint(9) NOT NULL AUTO_INCREMENT, `name` text, `team_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
npm test
License
MIT © [chopperlee]