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

后端 未结 5 1679
孤独总比滥情好
孤独总比滥情好 2020-12-09 19:40

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 r

5条回答
  •  爱一瞬间的悲伤
    2020-12-09 20:03

    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!
    

提交回复
热议问题