Hi Team
I am trying to establish a connection to the database schema that does not use sql connection. I am using node js as the back end, while running this project, i get the following error below;
`PS C:\Users\gcobani\coding-challenge\backend> yarn dev
yarn run v1.22.22
warning ..\package.json: No license field
$ tsx watch src/index.ts
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: SQLITE_CANTOPEN: unable to open database file] {
errno: 14,
code: 'SQLITE_CANTOPEN'
}
Node.js v18.20.4`
// This is my typescript and file path on the VS code project
import { Sequelize } from 'sequelize';
import path from 'path';
// The dbPath should reflect the location of the winedrops.db file
const dbPath = path.resolve(__dirname, 'db/winedrops.db'); // This should work if __dirname points to 'src'
console.log('Database path:', dbPath); // Log the path to confirm
export const sequelize = new Sequelize({
dialect: 'sqlite',
storage: dbPath,
});
async function testConnection() {
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error.message);
}
}
testConnection();