How to use the promise-mysql.createPool function in promise-mysql

To help you get started, we’ve selected a few promise-mysql 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 alice-si / etheroscope / dev-scripts / mysql-scripts / dropTable.js View on Github external
var mysql = require('promise-mysql')
var mysqlConnectionOptions = require('../../backend/settings.js').mysqlConnectionOptions

const pool = mysql.createPool(mysqlConnectionOptions)

var tableName = 'contracts' // !!! set table name hear!

function test () {
  pool.query('drop table ' + tableName)
    .then(function (results) {
      console.log('Drop table "' + tableName + '" results:\n ', results)
    })
    .catch(function (err) {
      console.log('Drop table "' + tableName + '" error:\n', err)
    })
}

setTimeout(test, 500)
github alice-si / etheroscope / backend / database-initiator / setupNewDatabase.js View on Github external
var mysql = require('promise-mysql')
var mysqlConnectionOptions = require('../common/settings.js').mysqlConnectionOptions

var optionsBeforeDBCreation = JSON.parse(JSON.stringify(mysqlConnectionOptions)) // full copy
delete optionsBeforeDBCreation['database'] // delete database field

console.log('opt\n', optionsBeforeDBCreation)

var pool = mysql.createPool(optionsBeforeDBCreation)

function createDatabase () {
  pool.query('create database etheroscope')
    .then(function (results) {
      console.log('Database creation success! results:\n ')
      pool = mysql.createPool(mysqlConnectionOptions)
    })
    .catch(function (err) {
      console.log('Database creation error:\n', err)
      pool = mysql.createPool(mysqlConnectionOptions)
    })
}

var sqlContracts = 'create table if not exists contracts(\n' +
  '    contractHash VARCHAR(40)  not null,\n' +
  '    name         VARCHAR(128),\n' +
github alice-si / etheroscope / dev-scripts / mysql-scripts / createDatabase.js View on Github external
var mysql = require('promise-mysql')
var mysqlConnectionOptions = require('../../backend/settings.js').mysqlConnectionOptions

var optionsBeforeDBCreation = JSON.parse(JSON.stringify(mysqlConnectionOptions)) // full copy
delete optionsBeforeDBCreation['database'] // delete database field

const pool = mysql.createPool(optionsBeforeDBCreation)

function test () {
  pool.query('create database etheroscope')
    .then(function (results) {
      console.log('Database creation success! results:\n ', results)
    })
    .catch(function (err) {
      console.log('Database cretion error:\n', err)
    })
}

setTimeout(test, 500)
github Snipa22 / nodejs-pool / init.js View on Github external
"use strict";
let mysql = require("promise-mysql");
let fs = require("fs");
let argv = require('minimist')(process.argv.slice(2));
let config = fs.readFileSync("./config.json");
let coinConfig = fs.readFileSync("./coinConfig.json");
let protobuf = require('protocol-buffers');
let path = require('path');

global.support = require("./lib/support.js")();
global.config = JSON.parse(config);
global.mysql = mysql.createPool(global.config.mysql);
global.protos = protobuf(fs.readFileSync('./lib/data.proto'));
global.argv = argv;
let comms;
let coinInc;

// Config Table Layout
// .

global.mysql.query("SELECT * FROM config").then(function (rows) {
    rows.forEach(function (row){
        if (!global.config.hasOwnProperty(row.module)){
            global.config[row.module] = {};
        }
        if (global.config[row.module].hasOwnProperty(row.item)){
            return;
        }
github ziad-saab / node-express-reddit-clone / index.js View on Github external
// Express middleware
var bodyParser = require('body-parser'); // reads request bodies from POST requests
var cookieParser = require('cookie-parser'); // parses cookie from Cookie request header into an object
var morgan = require('morgan'); // logs every request on the console
var checkLoginToken = require('./lib/check-login-token.js'); // checks if cookie has a SESSION token and sets request.user
var onlyLoggedIn = require('./lib/only-logged-in.js'); // only allows requests from logged in users

// Controllers
var authController = require('./controllers/auth.js');

/*
 Load the RedditAPI class and create an API with db connection. This connection will stay open as
 long as the web server is running, which is 24/7.
 */
var RedditAPI = require('./lib/reddit.js');
var connection = mysql.createPool({
    user: 'root',
    database: 'reddit'
});
var myReddit = new RedditAPI(connection);


// Create a new Express web server
var app = express();

// Specify the usage of the Pug template engine
app.set('view engine', 'pug');

/*
 This next section specifies the middleware we want to run.
 app.use takes a callback function that will be called on every request
 the callback function will receive the request object, the response object, and a next callback.
github oodavid / puppeteer-scraper / app / mysql / query.js View on Github external
async function getPool() {
  // From memory
  if(pool){
    return pool;
  }
  // Create the pool from settings
  let settings = await args.getMysqlSettings();
  settings.multipleStatements = true;
  pool = mysql.createPool(settings);
  return pool;
}
github alice-si / etheroscope / dev-scripts / mysql-scripts / showTables.js View on Github external
var mysql = require('promise-mysql')
var mysqlConnectionOptions = require('../../backend/settings.js').mysqlConnectionOptions

const pool = mysql.createPool(mysqlConnectionOptions)

function test () {
  pool.query('show tables')
    .then(function (results) {
      console.log('Show tables results:\n ', results)
    })
    .catch(function (err) {
      console.log('Show tables error:\n', err)
    })
}

setTimeout(test, 500)
github damian-pastorini / reldens / server / modules / dbpool.js View on Github external
var mysql = require('promise-mysql');

pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'admin22',
    database: 'questworld',
    connectionLimit: 10
});

function getSqlConnection() {
    return pool.getConnection().disposer(function(connection) {
        pool.releaseConnection(connection);
    });
}

module.exports = getSqlConnection;

promise-mysql

A bluebird wrapper for node-mysql

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis