abinop abinop - 18 days ago 6
MySQL Question

Is there a driver for mysql on nodejs that supports stored procedures?

I am looking for a mySQL driver for nodejs that supports stored procedures. http://nodejsdb.org/db-mysql/ that I have been using gives the error

PROCEDURE can't return a result set in the given context

Answer

it works in nodejs-mysql-native

stored procedure:

DELIMITER //
CREATE PROCEDURE test1p1()
  BEGIN
  SELECT 1+1;
  END //
DELIMITER ;

node.js script:

mysql = require('mysql-native');
var db = mysql.createTCPClient();
    db.auth('test', 'tester', ''); // db, user, password

db.query('call test.test1p1;').on('row', function(r) {
    console.log(r);
}).on('end', function() {
    console.log('OK!');
});

output:

{ '1+1': 2 }
OK!