I wrote a simple JS node file to query SQLite3 database with information I found on the Internet.
var sqlite3 = require('sqlite3').verbose(); var db = new sqlite3.database("restful.db"); var sql = "SELECT * FROM sensors"; db.all(sql, [], function(err, rows) { if (err) { throw err; } rows.forEach(function(row) { console.log(row.name); }); }); db.close();
However, I keep running into an error message as shown in the following image.
I have checked other similar questions, but they are not as helpful.
Isn’t new an operator? What am I doing Wrong?
Advertisement
Answer
According to the sqlite3 docs https://www.npmjs.com/package/sqlite3
database
starts with an uppercase D
as opposed to the lowercase d
so this
var db = new sqlite3.database("restful.db");
should be this
var db = new sqlite3.Database("restful.db");