I'm currently working through this tutorial that guides us in building an app with next.js. The tutorial involves using sqlite and performing database testing. One of the key components of the tutorial is the 'database-test.js' file:
const sqlite = require('sqlite');
async function setup() {
const db = await sqlite.open('./mydb.sqlite');
await db.migrate({force: 'last'});
const people = await db.all('SELECT * FROM person');
console.log('ALL PEOPLE', JSON.stringify(people, null, 2));
const vehicles = await db.all('SELECT * FROM vehicle');
console.log('ALL VEHICLES', JSON.stringify(vehicles, null, 2));
}
setup();
Upon running $node database-test.js, I encounter the following error:
(node:26446) UnhandledPromiseRejectionWarning: Error: sqlite: filename cannot be null / undefined
I'm puzzled by the requirement to open a .sqlite file instead of a .db file. Despite verifying the correct path to the .sqlite file, I remain unsure about the cause of this error and how to resolve it. Unfortunately, I've been unable to find any further information or examples of the .open function.