1.0.19 • Published 1 year ago
json-to-db v1.0.19
json-to-mysql
Easily convert your json file into mysql database tables. Features supported are 1. Table Creation 2. Table Alteration/Synchronization for Columns 3. Foreign Keys 4. UUID support for Primary and Foreign Keys 5. Arrays supported 6. Special Count column for arrays 7. Specify start import from specific object
Installation
npm i --save json-to-db
Required Parameters
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
Sample Usage
const j = require('json-to-db')
require('dotenv').config()
j.processFile('file.json')
Few Samples
file2.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"
}
}
}
}
}
Generated Schema
file5.json
{
"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [{
"value": "New",
"onclick": "CreateNewDoc()"
}, {
"value": "Open",
"onclick": "OpenDoc()"
}, {
"value": "Close",
"onclick": "CloseDoc()"
}
]
}
}
}
Generated Schema
1.0.19
1 year ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago