How to use the mysql/lib/Connection.prototype function in mysql

To help you get started, we’ve selected a few 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 bookercodes / communitycasts.co / source / app.js View on Github external
var path            = require('path');
var bodyParser      = require('body-parser');
var mysql           = require('mysql');
var validator       = require('express-validator');
var moment          = require('moment');
var promise         = require('bluebird');
var session         = require('express-session');
var flash           = require('express-flash');
var sitemap         = require('sitemap');

var screencasts     = require('./routes/screencasts');
var screencastsApi  = require('./routes/screencastsApi');

var app = express();

promise.promisifyAll(require('mysql/lib/Connection').prototype);

connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: process.env.MYSQL_PASSWORD || '',
  database: 'communityCasts'
});
connection.connect();

// settings
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// middlware
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({ extended: false }));
github bookercodes / communitycasts.co / admin.js View on Github external
#!/usr/bin/env node

var promise  = require('bluebird');
var readline = require('readline');
var mysql    = require('mysql');
var prompt   = require('prompt');

promise.promisifyAll(require('mysql/lib/Connection').prototype);
promise.promisifyAll(prompt);

var terminal = readline.createInterface(process.stdin, process.stdout);
var connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'password',
  database: 'screencastHub',
  multipleStatements: true,
});
connection.connect();

console.log('Hello. Here are your options:')
console.log(' 1. Approve pending screencasts interactively \n 2. Define tag synonym')

terminal.question('Option: ', function(option) {
github grncdr / node-any-db / packages / any-db-mysql / index.js View on Github external
MySQLConnection.prototype.query = function(text, params, callback) {
  var stream = adapter.createQuery(text, params, callback)
  this.emit('query', stream)
  Connection.prototype.query.call(this, stream.query)
  return stream
}
github paldepind / synceddb / persistence / mysql / index.js View on Github external
'use strict';

const mysql = require('mysql');
const bluebird = require('bluebird');
bluebird.promisifyAll(mysql);
bluebird.promisifyAll(require('mysql/lib/Connection').prototype);
bluebird.promisifyAll(require('mysql/lib/Pool').prototype);

let nextKey;

function getNewKey(con) {
  return con.queryAsync(
    'SELECT MAX(`key`) AS `max` FROM synceddb_changes'
  ).spread(function(res) {
    return (res[0].max !== null) ? res[0].max + 1 : 0;
  });
}

function create(opts) {
  const p = new mysqlPersistence(opts);
  return p.connection.queryAsync(
    'CREATE TABLE IF NOT EXISTS `synceddb_changes` ' +
github wbyoung / azul / lib / adapters / mysql / mysql.js View on Github external
'use strict';

var _ = require('lodash');
var Promise = require('bluebird');
var Adapter = require('../base');
var mysql = require('mysql');

Promise.promisifyAll(mysql);
Promise.promisifyAll(require('mysql/lib/Connection').prototype);

var returning = require('../mixins/returning'),
  EmbedPseudoReturn = returning.EmbedPseudoReturn,
  ExtractPseudoReturn = returning.ExtractPseudoReturn;

/**
 * MySQL Adapter.
 *
 * @public
 * @constructor
 * @extends Adapter
 */
var MySQLAdapter = Adapter.extend(/** @lends MySQLAdapter# */ {

  /**
   * Connect for MySQLAdapter.