How to use the promise-mysql.createConnection 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.

github snollygolly / borrow-bot / index.js View on Github external
co(function *(){
  // set up a connection for the database
  connection = yield mysql.createConnection({
      host: config.db.host,
      user: config.db.user,
      password: config.db.password,
      database: config.db.database
  });
  // login to redit and get your information
  let loginResult = yield reddit('/api/v1/me').get();
  console.log(`** : ${loginResult.name} has logged in.`);
  //get a listing of all new posts on the front page
  let listingResult = yield reddit('/r/borrow/new').listing();
  for (let post of listingResult.get.data.children){
    let newPost = processPost(post.data);
    let user = yield getUser(newPost.poster);
    if (newPost.type == "REQ"){
      // generate a score for all requested loans
      let score = generateScore(newPost, user);
github burgerbuds / swiff / src / database.js View on Github external
const doDropAllDbTables = async config => {
    let errorMessage
    const defaultConfig = {
        multipleStatements: true,
        host: null,
        user: null,
        password: null,
        database: null,
    }
    // Create the connection to the local database
    const conn = await mysql
        .createConnection({ ...defaultConfig, ...config })
        .catch(error => (errorMessage = error))
    if (errorMessage) return new Error(errorMessage)
    conn.query(dropDbQuery)
    conn.end()
}
github LeadcoinNetwork / Web-App-Project / backend / models / mysql-pool / mysql-pool.ts View on Github external
private init() {
    mysql
      .createConnection({
        host: this.config.mysql.host,
        port: this.config.mysql.port,
        user: this.config.mysql.user,
        password: this.config.mysql.password,
        database: "leadcoin",
      })
      .then(conn => {
        return conn.end()
      })
      .catch(err => {
        if (this.config.env != "test") {
          console.log("Failed to connect to mysql:", err.message)
        }
        setTimeout(this.init, 2000)
      })
github colophonemes / drupal-to-markdown / run.js View on Github external
promiseWhile(function(){ if(connectionAttempts>10){ throw new Error ( "Cannot connect after 10 attempts" ) }; connectionAttempts++; return !connection},function(){
        console.log(statusMsg('Connecting to MySQL... ',(connectionAttempts>1?'(attempt '+connectionAttempts+')':'') ) );
        return mysql.createConnection({
          host     : dbhost,
          port     : dbport,
          user     : dbuser,
          password : dbpassword,
          database : dbname
        }).then(function(conn){
            connection = conn;
        }).catch(function(err){
            console.error(err);
        });
    })
    .then(function(){
github IBM / ibm-cloud-functions-serverless-apis / actions / cat-delete-action / index.js View on Github external
return new Promise(function(resolve, reject) {
    console.log('Connecting to MySQL database');
    var mysql = require('promise-mysql');
    var connection;
    mysql.createConnection({
      host: params.MYSQL_HOSTNAME,
      port: params.MYSQL_PORT,
      user: params.MYSQL_USERNAME,
      password: params.MYSQL_PASSWORD,
      database: params.MYSQL_DATABASE
    }).then(function(conn) {
      connection = conn;
      console.log('Querying');
      var queryText = 'DELETE FROM cats WHERE id=?';
      var result = connection.query(queryText, [params.id]);
      connection.end();
      return result;
    }).then(function(result) {
      console.log(result);
      resolve({
        statusCode: 200,
github Xetera / HifumiOld / bot.js View on Github external
static Connect() {
        return mysql.createConnection({
            host: 'localhost',
            user: 'root',
            password: config.mySql.password,
            database: 'discord'
        });
    }
    static CreateTable(tableName) {
github snollygolly / borrow-bot / ingestion / helpers / common.js View on Github external
function createConnection(){
  return mysql.createConnection({
      host: exports.config.db.host,
      user: exports.config.db.user,
      password: exports.config.db.password,
      database: exports.config.db.database
  });
}
github snollygolly / borrow-bot / site / models / accounts.js View on Github external
module.exports.modifyAccount = function* modifyAccount(account){
	const connection = yield mysql.createConnection({
		host: config.db.host,
		user: config.db.user,
		password: config.db.password,
		database: config.db.database
	});
	let results = yield connection.query("UPDATE accounts SET ? WHERE id = ?;", [account, account.id]);
	return results;
};

promise-mysql

A bluebird wrapper for node-mysql

MIT
Latest version published 5 months ago

Package Health Score

70 / 100
Full package analysis