@verycrazydog/mysql-parser
A parser for MySQL statements. The current goal is to solve the missing DELIMITER syntax support
in Node.js module mysql.
Usage
Split into an array of MySQL statement, one statement per array item
const splitResult = mysqlParser.split(`
SELECT 1;
SELECT 2;
DELIMITER ;;
SELECT 3;;
DELIMITER $$
SELECT 4$$
DELIMITER ;
SELECT 5;
SELECT 6;
`)
console.log(splitResult)
Split into an array of MySQL statement, allow multiple statements per array item
const splitResult = mysqlParser.split(`
SELECT 1;
SELECT 2;
DELIMITER ;;
SELECT 3;;
DELIMITER $$
SELECT 4$$
DELIMITER ;
SELECT 5;
SELECT 6;
`, { multipleStatements: true })
console.log(JSON.stringify(splitResult))
License
This module is licensed under the MIT License.
Acknowledge
This module was built by referencing the following materials: