Run My SQL File
Run My SQL File is a NPM package that can run .sql script files.
For now it only supports mysql.
Installation
You can install it using NPM
npm install run-my-sql-file
Usage
First you need to pass the connection options, it supports all the mysql's createConnection options (host, password, user, etc).
Example:
const Runner = ; //SETTING THE OPTIONSRunner;
And then when all the options are set, you can execute the runFile function.
Example:
const file1_path = __dirname + "/scripts/script1.sql"; const file2_path = "../script2.sql"; const file3_path = "./script3.sql"; //IT WILL RUN THE FILE 3Runner;
Full example:
const Runner = ; //SETTING THE OPTIONSRunner; const file1_path = __dirname + "/scripts/script1.sql"; const file2_path = "../script2.sql"; const file3_path = "./script3.sql"; //IT WILL RUN THE FILE 3Runner;
Source code
The source code is avaliable in github