trying to parse returned results...

243 views
Skip to first unread message

Brad Thomas

unread,
Aug 3, 2015, 8:30:43 AM8/3/15
to node-firebird
Hi everyone

I'm using Meteor (www.meteor.com) to connect to a Firebird instance on my localhost.

Everything works up until this point: (using the sample Firebird database)

db.query('SELECT * FROM CUSTOMER', function(err,json) {
              
              console.log(json);
              db.detach;

as per the docs.

What do I do now with the "json" results?

I did console.log(json) and see something like this:

{ cust_no: 1014,
 customer: <Buffer 44 79 6e 6f 20 43 6f 6e 73 75 6c 74 69 6e 67>,
contact_first: <Buffer 47 72 65 74 61>,
contact_last: <Buffer 48 65 73 73 65 6c 73>,
phone_no: <Buffer 30 32 20 35 30 30 20 35 39 34 30>,
address_line1: <Buffer 52 75 65 20 52 6f 79 61 6c 65 20 33 35 30>,
address_line2: null,
city: <Buffer 42 72 75 73 73 65 6c 73>,
state_province: null,
country: <Buffer 42 65 6c 67 69 75 6d>,
postal_code: <Buffer 31 32 31 30>,
on_hold: null },
 { cust_no: 1015,
customer: <Buffer 47 65 6f 54 65 63 68 20 49 6e 63 2e>,
contact_first: <Buffer 4b 2e 4d 2e>,
 contact_last: <Buffer 4e 65 70 70 65 6c 65 6e 62 72 6f 65 6b>,
phone_no: <Buffer 28 30 37 30 29 20 34 34 20 39 31 20 31 38>,
address_line1: <Buffer 50 2e 30 2e 42 6f 78 20 37 30 32>,
address_line2: null,
city: <Buffer 44 65 6e 20 48 61 61 67>,
state_province: null,
country: <Buffer 4e 65 74 68 65 72 6c 61 6e 64 73>,
postal_code: <Buffer 32 35 31 34>,
 on_hold: null }

etc etc

What / how do I process the <Buffer entries inside each element of the JSON array?

Thanks

Brad



Henri Gourvest

unread,
Aug 3, 2015, 8:43:05 AM8/3/15
to node-firebird
Hello,

It is a common error in many Firebird databases.
You didn't set a character set on your string fields, but nodejs is UNICODE.
node-firebird can't determine if it is a binary field or a string field.
You should fix your database first.

You can use fbclone to fix it automatically:
https://github.com/zedalaye/fbclone

regards

Adrian Marius Popa

unread,
Aug 3, 2015, 9:56:03 AM8/3/15
to node-firebird
You can convert to UTF-8 this way 

is better to create the database utf-8 also all strings inserted must be utf-8 
Reply all
Reply to author
Forward
0 new messages