SQLImporter for Nodejs
An npm Modul. Node.js
Import your *.sql files with multiple sql-statements to your MySQL database.
Installation to Node dependency
- Make shure that you have
sqlimporter
installed locally:
npm i @derherrgammler/sqlimporter
- Create *.sql file like my example.sql:
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *\
Database Recreation
\* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
DROP DATABASE IF EXISTS example;
CREATE DATABASE example;
USE example;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *\
Tabblecreation
\* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
CREATE TABLE testtable (
`row1` CHAR(9) NOT NULL PRIMARY KEY,
`row2` VARCHAR(255) NOT NULL,
`row3` INT(11) NOT NULL
);
You have to undertstand that there can be Comments but ONLY multiline comments work aktually. I try to change this that also single line comments cna be used in the file.
If you want a new Version with deleting also singleline comments please write a issue in GitHub!
- Require and usage:
var sqlimport = require("@derherrgammler/sqlimporter");
var connConfig = {
host : 'localhost',
user : 'root',
password : 'root'
};
sqlimport.config(connConfig);
.importFile("/example.sql");
Authors
- Felix Herold - DerHerrGammler
License
This project is licensed under the MIT License - see the LICENSE file for details