Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Connect to Multiple Databases on one Server Using MSSQL NPM Package

I have a server set up and I am using "mssql" npm package to set up the database connections for my query routes. I want just one route in the whole server to be using a different database that is at a different IP address than the rest of the routes.

I have two different configs, configA and configB. This is my route set up:

router.get("/:code", function (req, res) {
  var sql = require("mssql");

    sql.connect(configA/B, function (err) {
      if (err) console.log(err);

      var request = new sql.Request();

      request.query("some query",
        function (err, recordset) {
          if (err) console.log(err);

          res.send(JSON.stringify(recordset));
        }
      );

    });

});

However, if I go to a page that uses a route with configA and then navigate to a page that uses a route with configB, configA just remains as the config, if that makes sense. I really just want to be able to use configA for routes 1, 2, and 3, and configB for route 4, but I am not able to as it always takes the already existing config.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!