redblaze / node-mysql

A wrapper of the node.js mysql package to make it a bit easier to use.
MIT License
60 stars 17 forks source link

Select query from Different Databases (on same server) #6

Open k0st8 opened 8 years ago

k0st8 commented 8 years ago

Hi, there. I was trying to do:

var cps = require('cps');
var db = require('node-mysql');

var box = new db.DB({{
 host: 'localhost',
 user: 'username',
 password: 'pass'
});

var basicTest = function(cb) {
    box.connect(function(conn, cb) {
        cps.seq([
            function(_, cb) {
                conn.query('select * from DATABASE.TABLE limit 12', cb);
            },
            function(res, cb) {
                console.log('Result:', res);
                cb();
            }
        ], cb);
    }, cb);
};

basicTest(function(){
    console.log("Done");
}); 

Cannot get results without connecting to specific DATABASE

Singwai commented 7 years ago

I believe you can just connect to any database and write your query with the DATABASE.TABLE format.