Skip to content

zeromod/json-to-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JSON to SQL converter

Setup

  • cd json-to-sql
  • npm i

usage

node converter.js path-to-input.json path-to-output.sql

Limitations

Parses only below schema from json

  {
     "tableName": "tableContents"//this can be an array of another object or just an object
  }

Example

input.json

{
    "User": [
        {
            "id": 123,
            "name": "username1"
        },
        {
            "id": 321,
            "name": "username2"
        }
    ],
    "Address": {
        "city": "Chennai",
        "state": "Tamilnadu"
    }
}

output.sql

CREATE TABLE IF NOT EXISTS User (id INTERGER,name TEXT);
CREATE TABLE IF NOT EXISTS Address (id INTERGER,name TEXT,city TEXT,state TEXT);
INSERT INTO User (id,name) VALUES (123,"username1");
INSERT INTO User (id,name) VALUES (321,"username2");
INSERT INTO Address (city,state) VALUES ("Chennai","Tamilnadu");

About

json to sql converter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published