I have created an export of a sql database (all tables and views) from MySQL Workbench. After removing the database drop/create lines, I am able to run the contents of the export file through the SQL engine to recreate the tables and views over and over again without any trouble.
However when I try to stuff the contents of the file through felixge/node-mysql I get syntax errors.
Is there a standard way of handling this pattern with node-mysql?
Attached is the entire contents of the SQL file that I'm trying to get node-mysql to execute on a database. It fails whether the database is empty or already has tables in it.
SQL File: http://pastebin.com/YjuDbyEK
NODE CODE:
var db = new mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'admin',
database : 'nps',
multipleStatements : true
});
//Check for the SQL upgrade file and stuff the contents through node-mysql
fs.exists(setting.NPS_loadFile, function(exists) {
if(exists){
fs.readFile(setting.NPS_loadFile, 'utf-8', function(err, sql) {
if (err) {
console.log("Couldn't read " + setting.NPS_loadFile, red(err));
}
else {
db.connect();
db.query(sql,function(e,r){
if(e == null){
console.log(cyan('Database structure upgraded.'));
}else{
sendError(ws,"<h1>SQL Error during upgrade</h1>"+e,e);
}
});
}
});
}else{
console.log("Couldn't read " + setting.NPS_loadFile, red(err));
}
});