I’m running a small MySQL database locally on my computer for a personal project. To make entering data easier, I wrote up a bare-bones website interface. Everything works fine, the data gets put in the database, it can update entries, etc. However, the Node web server only sends 6 queries. After 6, it just stops sending anything.
Thus far, I’ve worked around it by restarting the node server after every 6 entries. However, that (obviously) gets annoying very fast.
Is there a way to refresh the connection or increase the number of queries allowed?
After some research, I learned about mysql.createPool()
which, after replacing .createConnection()
, I still only can do 6 queries.
I’ve also had the thought of closing the connection (when I was using .createConnection()
) and then reconnecting.
The only other potential I can come up with is that the problem is on the database side, where it only allows 6 queries per connection or something. (and restarting the node classifies as a new connection)
Node.js DB code
const mysql = require("mysql2");
// Database Connection
var con = mysql.createPool({
host: "localhost",
database: "....",
user: "....",
port: ....,
password: "...."
});
// Only used with mysql.createConnection()
// con.connect((err) => {
// if(err) throw err;
// console.log("Database Connected");
// })
app.post("/input", (req,res) => {
if(req.body.code) {
addToDatabase(....);
} else {
addToDatabase(....);
}