Starting learning node-sqlite3, using version 3.1.4 of sqlite3 installed from binaries using npm, with node 4.4.7 and Fedora 23. The installed sqlite packages are:
[giacecco@giaceccos-linux twitter2rss]$ sudo dnf list installed | grep sqlite
mono-data-sqlite.x86_64 4.0.5-3.fc23 @updates
sqlite.x86_64 3.11.0-3.fc23 @updates
sqlite-devel.x86_64 3.11.0-3.fc23 @updates
sqlite-libs.i686 3.11.0-3.fc23 @System
sqlite-libs.x86_64 3.11.0-3.fc23 @updates
This simple Node script immediately gives me an SQLITE_MISUSE: out of memory error:
const sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database("foobar.sqlite3", sqlite3.OPEN_CREATE, function (err) {
if (err) console.log(err.message);
});
What am I doing wrong? This is too simple for being a bug. Thanks!
I got it: when creating a database, it is not implied that we're opening, too, so it is necessary to specify the opening modality, as in the example below:
const sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database("./foobar.sqlite3", sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, function (err) {
if (err) console.log(err.message);
});
Most helpful comment
I got it: when creating a database, it is not implied that we're opening, too, so it is necessary to specify the opening modality, as in the example below: