Socket
Socket
Sign inDemoInstall

json2mysql

Package Overview
Dependencies
14
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    json2mysql

A tool for comparing your configure json file with mysql table, then Loaded


Version published
Weekly downloads
38
increased by1166.67%
Maintainers
1
Install size
3.00 MB
Created
Weekly downloads
 

Readme

Source

json2mysql

NPM version Build Status Downloads Code Style

A tool to load a JSON/JS object file to Mysql.

Install

npm i json2mysql

Usage

import json2mysql from "json2mysql"

const dbconfig = {}
const jm = json2mysql(dbconfig)
jm.load(tableName, file)
jm.replace(tableName, file)

Methods

  • 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 index

Test

  • docker-compose up -d will create database container
  • create a test table in your database:
  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

License

MIT © [chopperlee]

Keywords

FAQs

Last updated on 07 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc