0
I am studying how to develop an API to query data from a Firebird database. To do this I am using the Node-Firebird, but the connection does not seem to be working.
Follows excerpt from the code:
const firebird = require('node-firebird');
var options = {};
options.host = '127.0.0.1';
options.port = 3050;
options.database = 'C:/PASTA/DADOS/BANCO.FDB';
options.user = 'SYSDBA';
options.password = 'masterkey';
options.lowercase_keys = false; // set to true to lowercase keys
options.role = null; // default
options.pageSize = 4096;
const consulta = firebird.attach(options, (err, db) => {
if (err){
//throw err;
}
else{
db.query('SELECT * FROM UCTABUSERS', function(err,result){
try{
console.log('A função funcionou');
this.usuarios = result;
db.detach();
}catch{
throw err;
}
});
}
return this.usuarios;
});
module.exports = consulta;
I use this function in another javascript file. The problem is that there is no message or error, only the return that is empty.
Does anyone have any idea what might be going on?
I solved this problem using another method from this library. I used the pool method to open the connection and query. Follow the code excerpt:
– Gustavomgu.developer
const Rows = async () => { Try{ Try{ var pool = client.pool(5, options); pool.get(Function(err, db) { Try{ db.query("SELECT * FROM UCTABUSERS Where UCIDUSER = 1", Function(err, result) { setResult(result); db.detach(); }); }catch{ console.log(err); Return err; } }); pool.Destroy();
– Gustavomgu.developer
console.log('Return': '+ getResult(); Return getResult(); }catch{ Return 'Unable to open connection'; } }catch{ Return"Unable to connect to database"; } };
– Gustavomgu.developer
Gustavo could post the complete code corrected, because I have the same problem, and as I am new with Node.js I could not understand where to change the code.
– eduardo lima