Answers for "nodejs mysql set query timeout"

0

nodejs mysql set query timeout

// Kill query after 60s
connection.query({sql: 'SELECT COUNT(*) AS count FROM big_table', timeout: 60000}, function (error, results, fields) {
  if (error && error.code === 'PROTOCOL_SEQUENCE_TIMEOUT') {
    throw new Error('too long to count table rows!');
  }
 
  if (error) {
    throw error;
  }
 
  console.log(results[0].count + ' rows');
});
Posted by: Guest on May-01-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language