dimanche 29 novembre 2015

Unexpected output from retrieving SQLite in Node JS

I have been trying to use sqlite3 for a database with node js. With this code:

var sqlite3 = require('sqlite3').verbose();
var file = "inventory";
var db = new sqlite3.Database(file);
var list;
db.all("SELECT * FROM bob", function(err, rows) {
        rows.forEach(function (row) {
            list = row.itemName;
        })
    });
db.close();

console.log(list);

I am not getting what I expected, I am just getting 'undefined'. As an output I was expecting to get the value of row.itemName but I am not.

Could anyone help?

Thanks

David

Aucun commentaire:

Enregistrer un commentaire