I am trying to change database in an existing connection in node.
The connection may or may not have database name in createConnection
call.
Here's the code:
var mysql = require('mysql');
connection = mysql.createConnection( {
host : 'localhost',
user : 'me',
password : 'secret',
port : 3306,
/* database : 'test' // optional */
});
I am using node-mysql lib. Currently I'm closing the connection and re-connecting.
Is there any better way to do that? Similar to mysql_select_db
in php?