Easily convert your json file into mysql database tables. Features supported are
- Table Creation
- Table Alteration/Synchronization for Columns
- Foreign Keys
- UUID support for Primary and Foreign Keys
- Arrays supported
- Special Count column for arrays
- Specify start import from specific object
npm i --save json-to-db
These can be passed as environment variables or be placed in a .env file and make use of dotenv package to load them.
- SYNCHRONIZE=true/false (whether to update the database tables, little slower since it checks schema before every insert)
- PARENT=
glossary.GlossDiv
(Feature# 7) - DB_NAME=
db name
- DB_HOST=
db host
- DB_PORT=
db port
- DB_USER=
user
- DB_PASSWORD=
password
const j = require('json-to-db')
require('dotenv').config()
j.processFile('file.json')
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
{
"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [{
"value": "New",
"onclick": "CreateNewDoc()"
}, {
"value": "Open",
"onclick": "OpenDoc()"
}, {
"value": "Close",
"onclick": "CloseDoc()"
}
]
}
}
}