Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (v200) {
// V2.0+ API
this._dbClient = mysql.createConnection({
host : this._connectionParams.host,
user : this._connectionParams.user,
password : this._connectionParams.password,
port : this._connectionParams.port,
database : this._connectionParams.database
});
this._dbClient.connect( _.bind( this._onConnectionInitialization, this ) );
} else {
// Old APIs
if( v092 ) {
this._dbClient = mysql.createClient();//V0.9.2+ API
} else {
this._dbClient = new mysql.Client();//old API
}
this._dbClient.host = this._connectionParams.host;
this._dbClient.port = this._connectionParams.port;
this._dbClient.user = this._connectionParams.user;
this._dbClient.password = this._connectionParams.password;
this._dbClient.database = this._connectionParams.database;
if( v092 ) {
this._onConnectionInitialization( null );//V0.9.2+ API : no explicit "connect()"
} else {
this._dbClient.connect( _.bind( this._onConnectionInitialization, this ) );//old API
}
}
};
fs = require('fs'),
crypto = require('crypto'),
Client = require('mysql').Client,
parser = require('uglify-js').parser,
uglifyer = require('uglify-js').uglify;
var RedisStore = require('connect-redis')(express);
/* ==============================================================
Configuration
=============================================================== */
//used for session and password hashes
var salt = '20sdkfjk23';
var client = new Client();
client.host = 'hostname';
client.user = 'username';
client.password = 'password';
client.database = 'bookmarks';
var app = express.createServer();
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: salt, store: new RedisStore, cookie: { maxAge: 3600000 * 24 * 30 } }));
app.use(express.methodOverride());
app.use(express.logger({ format: ':method :url' }));
delete express.bodyParser.parse['multipart/form-data'];
app.use('/css', express.static(__dirname + '/public/css'));
function setup_db2(cb) {
var _settings = clone(settings.db2);
delete _settings.database;
var client;
try {
client = mysql[conn_method](_settings);
} catch (e) {
client = new mysql.Client(_settings);
client.connect();
}
client.query('CREATE DATABASE ' + settings.db2.database, function (err) {
client.end();
if (!(err && (err.number == mysql.ERROR_DB_CREATE_EXISTS || err.number == 1007))) {
throw err;
}
cb(null);
});
}
function setup_db(cb) {
var _settings = clone(settings.db1);
delete _settings.database;
var client;
try {
client = mysql[conn_method](_settings);
} catch (e) {
client = new mysql.Client(_settings);
client.connect();
}
client.query('CREATE DATABASE ' + db, function (err) {
if (!(err && (err.number == mysql.ERROR_DB_CREATE_EXISTS || err.number == 1007))) {
throw err;
}
});
client.query('USE ' + db);
client.query('drop table if exists widgets');
client.query(table_sql, function (err) {
client.end();
assert.ifError(err);
cb(null, true);
});
}
var mysql = require('mysql'),
sys = require("sys"),
undef;
var client = new mysql.Client;
exports.debugMode = false;
exports.useCache = false;
function ucwords(str) {
str = str.split("_");
for (i = 0; i < str.length; ++i) {
str[i] = str[i].substring(0, 1).toUpperCase() + str[i].substring(1).toLowerCase();
}
return str.join('');
}
function debug (m) {
if (exports.debugMode) {
create: function (callback) {
var client;
if (mysql.hasOwnProperty(conn_method)) {
client = mysql[conn_method](settings);
} else {
console.log("\nEasyMySQL [WARNING]: node-mysql 0.9.1 support is deprecated.\n");
client = new mysql.Client(settings);
client.connect();
}
callback(null, client);
},
}, function (body) {
var configuration = JSON.parse(body);
mysql = configuration.databases.mysql
client = new Client()
client.host = mysql.hostname
client.user = mysql.user
client.password = mysql.password
client.database = mysql.name
client.query("\
SELECT columns.* \
FROM information_schema.tables AS tables \
JOIN information_schema.columns AS columns USING (table_schema, table_name) \
WHERE table_type = 'BASE TABLE' AND tables.table_schema = ? \
", [ mysql.name ], async());
}, function (results) {
results.forEach(function (column) {
var sys = require('sys'),
fs = require('fs'),
Client = require('mysql').Client;
var client = new Client();
exports.close = function() {
client.end();
}
exports.reconnect = function() {
exports.initialize(function(){});
}
exports.initialize = function(callback) {
this._getDatabaseSettingsFromConfig(function (hostname, username, password, database){
client.user = username;
client.password = password;
client.host = hostname;
client.connect();
client.query('USE ' + escape(database));
function getClient() {
var client = new mysql.Client(db_cred);
client.database = 'shoutbox';
client.connect();
return client;
}