How to use the mysql2/promise.js.createPool function in mysql2

To help you get started, we’ve selected a few mysql2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisveness / koa-sample-web-app-api-mysql / lib / mysqldb.js View on Github external
async function setupConnectionPool() {
    const dbConfig = MysqlDb.connectionParams();
    dbConfig.namedPlaceholders = true;
    connectionPool = mysql.createPool(dbConfig);
    debug('MysqlDb.setupConnectionPool', `connect to ${dbConfig.host}/${dbConfig.database}`);

    // traditional mode ensures not null is respected for unsupplied fields, ensures valid JavaScript dates, etc
    await connectionPool.query('SET SESSION sql_mode = "TRADITIONAL"');
}