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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -