Search code examples
mysqlnode.jserror-handlingnode-mysql

How can I fetch the warnings after node-mysql queries


How can I fetch the corresponding warning identified after the query execution as in:

connection.query( squery, function(err, rows){
   ... 
   // search for OkPacket in 2 dimension array
   var warningCounter = okPacket.warningCount;
   if ( warningCounter > 0 ){
      ???
   }

});

Solution

  • Execute the query:

    SHOW WARNINGS
    

    Here is more on SHOW WARNINGS Syntax