jeudi 5 novembre 2015

Running sqlite3 query in node.js returns `undefined` rows with no error

Using Node.js 5.0.0 with sqlite3 3.1.1 The following code -

var sqlitedb = new sqlite3.Database(sqliteFilename);
sqlitedb.serialize(function() {

   sqlitedb.run("SELECT ZDATA FROM ZMYTABLE;", function(err, rows) {
      console.log(rows);
   });

});
sqlitedb.close();

Prints undefined in the console, but if the same query is executed using the sqlite3 tool, it works fine -

$ sqlite3 backup.sqlite 
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> SELECT ZDATA FROM ZMYTABLE;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://ift.tt/vvUEPL">
...

Any idea why SQL returns undefined rows in Node.js?

Aucun commentaire:

Enregistrer un commentaire