Max Power
Max Power

Reputation: 53

How can I use two database connections in node.js? (mysql)

I want to make requests for two databases using express and mysql modules and listen on port 8000.

Upvotes: 2

Views: 12279

Answers (1)

You could create multiple db connections using mysql node package like:

var mysql      = require('mysql');

var connection = mysql.createConnection({...});
var otherConnection = mysql.createConnection({...});

See node-mysql documentation

createConnection creates a new, separate database connection object on each call.

Upvotes: 2

Related Questions