Load a JSON/JS object file to Mysql.
A tool to load a JSON/JS object file to Mysql.
npm i json2mysql
import json2mysql from "json2mysql"
const dbconfig = {}
const jm = json2mysql(dbconfig)
jm.load(tableName, file)
jm.replace(tableName, file)
load
: this will disable foreign key, remove table rows , then load json and enable foreign key replace
: this will replace table rows with json file, by comparing table id with array indexdocker-compose up -d
will create database container
CREATE TABLE `user` (
`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
MIT © [chopperlee]