Run SELECT command in Firebird database with Javascript

Asked

Viewed 174 times

-1

Hello, I made a code to execute a select in a database Firebird using javascript, with the library Node-Firebird, the code is this:

firebird.attach(options, (err, db) => {
if (err)
    throw err

db.sequentially(sentence, (row, index) => {
    console.log(row)
}, (err) => {
    db.detach()
})

})

the problem is that the result of this Row, which I believe should be the table data comes like this:

{
  CLIENTE: <Buffer 30 30 30 30 37 37>,
  NOME: <Buffer 4d 4f 4e 54 45 53 20 43 4c 41 52 4f 53>,
  RAZAO: <Buffer 4e 41 59 41 52 41 20 46 45 52 52 45 49 52 41 20 52 41 42 45 4c 4f>,
  ENDERECO: <Buffer 52 55 41 20 42 20 39 31>,
  BAIRRO: <Buffer 52 41 55 4c 20 4c 4f 55 52 45 4e c7 4f>,
  ESTADO: <Buffer 4d 47>,
  VENDEDOR: <Buffer 30 30 30 30 30 32>
}

How to actually take the data instead of these "Buffers" ?

2 answers

0

I’m having the same problem, but entering the code that Victor mentioned above also does not work.

firebird.attach(options, (err, db) => {
if (err)
    throw err

db.query(sentence, (err, result) => {
    console.log(result)
    db.detach()

})

My doubt. Query returning buffer only in Firebird with Node

0

Sequentially is for sequential readings. You should also call next(). A simple JSON.stringify() should do it. So your code would look like:

firebird.attach(options, (err, db) => {
if (err)
    throw err

db.sequentially(sentence, (row, index, next) => {
    console.log(JSON.stringify(row));
    next();
}, (err) => {
    db.detach()
})

If you are not working with streaming/big data, I recommend changing the sequentially by the simple query. That way, your code would be almost the same, just switching to the query:

firebird.attach(options, (err, db) => {
if (err)
    throw err

db.query(sentence, (err, result) => {
    console.log(result)
    db.detach()

})

Browser other questions tagged

You are not signed in. Login or sign up in order to post.