Problems encountered in linking database with node mysql module

scene

I link to the database in three ways:

  • first: use .connect () .end () . Continuous requests can be made for the first time, and then there will be ups and downs
  • second: do not use .connect () .end () . Continuous requests. All requests are normal. reference there is a sentence in the document that However, a connection can also be implicitly established (implicitly links to) by invoking a query.. Why is the implicit link ok??
  • third: use link pooling mysql.createPool () . Continuous requests. All requests are normal

looked up all kinds of materials and encountered the same problem on GitHub. issues knows how to ok, with connection pooling and implicit links, but still wants to figure it out. And how to use the first .connect () .end () to achieve consecutive requests without reporting errors

var mysql      = require("mysql");
//   .connect() .end()
var connection = mysql.createConnection({
 // 
})
...
connection.connect()
connection.query(sql, function (error, results, fields) {
 // 
})
connection.end()
...

//   .connect() .end()
var connection = mysql.createConnection({
 // 
})
...
connection.query(sql, function (error, results, fields) {
 // 
})
...

//  
var pool = mysql.createPool({
 // 
})
...
pool.getConnection(function (err, connection) {
  connection.query(sql, function (error, results, fields) {
    connection.release();
    // 
  })
});
...
Dec.23,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bf42-2c2db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bf42-2c2db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?