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


i want make requests 2 databases using express , mysql modules , listen on port 8000.

you 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 new, separate database connection object on each call.


Comments

Popular posts from this blog

python - Best design pattern for collection of objects -

go - serving up pdfs using golang -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -