Connect node js with firebird

0

Hello everyone again ...

I have a FirBird 2.1 bd that is being used by a client application and I have done other things with php to publish on the web.

The point is that I want to build an ASP and I want to try node.js on the server side.

Will any of you have or will have made the connection to Firebird using node.js?

Thanks in advance.

Slds

    
asked by urivera_cl 01.02.2017 в 16:03
source

4 answers

0

Yes, it's super easy with this library:

Firebird Node

Then include the library in the project

var Firebird = require('node-firebird');

and there is an example taken from the same source that I passed to you

Firebird.attach(options, function(err, db) {

    if (err)
        throw err;
        db.query('SELECT * FROM TABLE', function(err, result) {
        db.detach();
    });

});
    
answered by 02.02.2017 / 12:09
source
0

Thanks Alexis,

I already installed the node-firebird, did the same example that you gave me where attach should be to establish the connection?

Well, throw me the following:

I have an I / O error but I do not know what it can be, can you lend me a hand?

Ulysses

    
answered by 03.02.2017 в 14:03
0

I enclose the code that is in file fb.js:

//
// conn firebird con node.js
//

// inyecciones
var http=require('http');
var url=require('url');
var fs=require('fs');
var querystring = require('querystring');
var firebird=require('node-firebird');

// opciones base de datos
var options = {};

options.host = '127.0.0.1';
options.port = 3050;
options.database = 'database.fdb';
options.user = 'SYSDBA';
options.password = 'masterkey';
options.lowercase_keys = false; // set to true to lowercase keys
options.role = null;            // default
options.pageSize = 4096;        // default when creating database

firebird.attach(options, function(err, db) {
    if (err)
        throw err;
    // db = DATABASE
    db.query('SELECT * FROM EMPRES', function(err, result) {
        // IMPORTANT: close the connection
        db.detach();
    });

});
    
answered by 03.02.2017 в 15:50
0

I was able to connect ... you had to write the entire route in options.database.

Now I can see a table using console.log, I'll see a more elegant way to show it by html and I'll publish my progress ...

Thanks

    
answered by 06.02.2017 в 20:22