Node-sqlite3: "SQLITE_MISUSE: out of memory" error creating a new database file

Created on 10 Jul 2016  路  1Comment  路  Source: mapbox/node-sqlite3

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!

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:

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);
});

>All comments

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);
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sveinnM picture sveinnM  路  25Comments

csugden picture csugden  路  30Comments

wotermelon picture wotermelon  路  24Comments

springmeyer picture springmeyer  路  29Comments

creationix picture creationix  路  22Comments