Answer the question
In order to leave comments, you need to log in
NW.js + SQLite = how to make it work???
Good afternoon.
I decided to study NW.JS and wanted to use one of my old crafts as a project, rewriting it for this framework. The matter is that in the old project, for data storage, the SQLite DB is used.
But since I've never come across NW.JS before, as well as NODE.JS, I'm probably doing something wrong, because when I try to repeat the primitive example (below), in dev.tools I get: Uncaught Error: Cannot find module 'sqlite3', even though package.json even says "dependencies": {"sqlite3": "^3.1.13"}.
The example itself:
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('database.sqlite');
db.serialize(function() {
db.run("CREATE TABLE if not exists user_info (info TEXT)");
var stmt = db.prepare("INSERT INTO user_info VALUES (?)");
for(var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();
db.each("SELECT rowid AS id, info FROM user_info", function(err, row) {
console.log(row.id + ": " + row.info);
});
});
db.close();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question