mysqlPool = mysql.createPool(args);
let mysqlPool = mysql.createPool(sqlConfig);
constructor(config) { this.pool = mysql.createPool({ host: config.mysql.host, port: config.mysql.port, user: config.mysql.user, password: config.mysql.password, database: config.mysql.database, connectionLimit: config.mysql.connectionLimit, ssl: config.mysql.ssl }); }
function createPool (cb) { setup(function () { _teardown = function teardown () { if (pool) { pool.end() pool = undefined } } var pool = mysql.createPool(connectionOptions) queryable = pool cb() }) }
constructor(config) { this.connection = mysql.createPool({ connectionLimit: 100, host: '127.0.0.1', user: 'root', password: 'root', database: 'chat', debug: false }); }
function service_init ( ) { return new Promise ( function ( resolve, reject ) { vm.connection_pool = mysql.createPool ( { connectionLimit : process.env.DB_SERVER_CONNECTION_LIMIT, host : process.env.DB_SERVER_HOST, port : process.env.DB_SERVER_PORT, database : process.env.DB_SERVER_DATA, user : process.env.DB_SERVER_USER, password : process.env.DB_SERVER_PASS } ); resolve ( vm.connection_pool ); } ); }
connect(){ var t = this; try{ var jo = { server : dbov.vars.server ,host : dbov.vars.host ,dbname : dbov.vars.dbname ,user : dbov.vars.user ,password : dbov.vars.password ,port : dbov.vars.port }; t.pool = mysql.createPool(jo); t.logger.debug('sql connection pool ok=' + JSON.stringify(jo)).tag(t.log.rte).tag(t.log.lne).tagline(); }catch(e){ t.logger.error("").tag(t.log.err.setInput(e.message)).tag(t.log.rte).tag(t.log.lne).tagline(); } }
function query(sqlString, values) { // Initialize the pool lazily, in case SQL access isn't needed for this // GCF instance. Doing so minimizes the number of active SQL connections, // which helps keep your GCF instances under SQL connection limits. if (!mysqlPool) { logger.debug('creating sql pool'); mysqlPool = mysql.createPool(mysqlConfig); } if (!values) values = []; return new Promise((resolve, reject) => { logger.debug('sending sql query'); mysqlPool.query(sqlString, values, (err, results) => { if (err) { reject(err); return; } logger.debug('query succeeded'); resolve(results); }); }); }
constructor() { //Instantiates the connection pool this.internalPool = mysql.createPool({ host: this.MYSQL_DB_ADDRESS, user: this.MYSQL_DB_USER, database: this.MYSQL_DB_NAME, password: this.MYSQL_DB_PASSWORD, connectionLimit: this.MYSQL_DB_POOL_SIZE, waitForConnections: true }) //Allows better control of openned connections this.registerThreadCounter() }
async function init() { const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST; const user = USER_FILE ? fs.readFileSync(USER_FILE) : USER; const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD; const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; await waitPort({ host, port : 3306, timeout: 15000 }); pool = mysql.createPool({ connectionLimit: 5, host, user, password, database, }); return new Promise((acc, rej) => { pool.query( 'CREATE TABLE IF NOT EXISTS todo_items (id varchar(36), name varchar(255), completed boolean)', err => { if (err) return rej(err); console.log(`Connected to mysql db at host ${HOST}`); acc(); }, ); }); }
function createPool (cb) { setup(function () { cb(mysql.createPool(utils.credentials())) }) }
function createPoolAndGetConnection (cb) { setup(function () { _teardown = function teardown () { if (pool) { pool.end() pool = undefined } } var pool = mysql.createPool(connectionOptions) pool.getConnection(function (err, conn) { if (err) throw err queryable = conn cb() }) }) }
private constructor(config: TypeConfig) { this.pool = mysql.createPool({ host: config.mysql.host, port: config.mysql.port, user: config.mysql.user, password: config.mysql.password, database: config.mysql.database, connectionLimit: config.mysql.connectionLimit, ssl: config.mysql.ssl }); }
// FUNCTION: Create connection pool createPool(settings) { return mySQL.createPool(settings); }
constructor(config) { this.config = config; this.pool = mysql.createPool(config); }