meteor-mssql icon indicating copy to clipboard operation
meteor-mssql copied to clipboard

Sql connections

Open jesperordrup opened this issue 9 years ago • 4 comments

Is it possible to initialize a sql connection in code instead of from settings? I would like to loop through a collection of connection settings and query each db for monitoring purposes.

/Jesper

Cool package - got it running in 10 minutes.

jesperordrup avatar Oct 14 '15 13:10 jesperordrup

Got it :+1:

Sql.connection = new Sql.driver.Connection(dbdata, Meteor.bindEnvironment(function (err) { if (err) {console.log("Can't connect to database");} else {

         query = "select top 5 * from sometable order by id desc";
         // Sync-style
         try {
           var res = Sql.q(query);

           return res;

         } catch (e) {
           debugger
           console.log(e);
         }

       }
    }));

And dbdata contains:

{

         "server"   : "123.123.123.123",
         "database" : "dbname",
         "user"     : "username",
         "password" : "somepass",
         "options"  : {
           "useUTC"     : false,
           "appName"    : "MSSSQL App"
         }

jesperordrup avatar Oct 15 '15 12:10 jesperordrup

I was wrong .. it reuses the first connection made. Is it possible at all?

jesperordrup avatar Oct 15 '15 14:10 jesperordrup

Ya we need a way to connect to multiple databases, the way it is now is pretty restrictive.

ClarenceL avatar Jan 22 '16 16:01 ClarenceL

Is there a solution to connect to multiple databases, now?

JensAttermeyer avatar Nov 16 '16 14:11 JensAttermeyer