Last active
November 19, 2017 17:04
-
-
Save artemtam/d4cce21b1a3b52a29f31b9f2a5625224 to your computer and use it in GitHub Desktop.
NodeJS MySQL connection pool creating
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 mysql = require('mysql'); | |
const {promisify} = require('util'); | |
const pool = mysql.createPool({ | |
connectionLimit: 10, | |
host: process.env.db.host, | |
user: process.env.db.user, | |
password: process.env.db.pass, | |
database: process.env.db.name, | |
multipleStatements: true | |
}); | |
pool.on('connection', function (connection) { | |
connection.query('SET NAMES "utf8mb4"'); | |
connection.query('SET lc_time_names = "ru_RU"'); | |
}); | |
pool.query = promisify(pool.query); | |
module.exports = pool; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment