I need to change Nodejs MySQL database connection at runtime.
Here is my code,
var mysql=require('mysql');
var connection = mysql.createConnection({ host : 'localhost', user : 'root', password : '', database : 'test' });
var connection2 = mysql.createConnection({ host : 'localhost', user : 'root', password : '', database : 'test1' });
connection.connect(function(err) { if (err) throw err; console.log('You are now connected...'); }); connection2.connect(function(err) { if (err) throw err; console.log('You are now connected...'); });
Do you have any idea about it?
Please share with me.
Thanks.