Created
July 12, 2017 14:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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