Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whimsyniche/48d177f501091b3b9b91755a5e0efa02 to your computer and use it in GitHub Desktop.
Save whimsyniche/48d177f501091b3b9b91755a5e0efa02 to your computer and use it in GitHub Desktop.
mysql,createpool() for node multiple database connection > https://github.com/mysqljs/mysql#pooling-connections
const express = require('express');
const app = express();
const mysql = require('mysql');
const pool = mysql.createPool({
connectionLimit : 10,
host: "localhost",
user: "yourusername",
password: "yourpassword"
});
app.post('/test', (req, res) => {
pool.query("SELECT * FROM Mytable", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment