I’m trying to connect to already encypted local Sqlite3 DB with @journeyapps/sqlcipher in an Electron App. i used db browser to encrypt the db with password. i got following error when try to connect to database.
Uncaught Error: Unable to find dialect at @journeyapps/sqlcipher at ConnectionManager._loadDialectModule (B:\rtapp\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:53) at new ConnectionManager (B:\rtapp\node_modules\sequelize\lib\dialects\sqlite\connection-manager.js:18) at new SqliteDialect (B:\rtapp\node_modules\sequelize\lib\dialects\sqlite\index.js:13) at new Sequelize (B:\rtapp\node_modules\sequelize\lib\sequelize.js:194) at tests.html:35
OS: Windows 10 Node: 20.11.1 Electron: 6.1.7 Sequelize: 6.37.1 @journeyapps/sqlcipher: 5.3.1
Package json:
`"name": "rt",
"version": "1.0.0",
"description": "rt tool application",
"productName": "rt tool",
"main": "index.js",
"icon": "./Images/logo1.ico",
"scripts": {
"start": "electron .",
"postinstall": " electron-builder install-app-deps",
"rebuild": "electron-rebuild -f -w sqlite3",
"build": "electron-packager . all"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^6.1.7",
"electron-builder": "^21.2.0",
"electron-packager": "^14.2.1",
"electron-winstaller": "^4.0.0"
},
"dependencies": {
"@journeyapps/sqlcipher": "^5.3.1",
"@stdlib/math": "0.0.11",
"body-parser": "*",
"bootstrap": "^3.4.1",
"csvtojson": "^2.0.10",
"datalize": "^0.3.4",
"datatables.net": "^1.10.20",
"datatables.net-dt": "^1.10.20",
"electron-context-menu": "^2.3.0",
"electron-css": "^0.14.4",
"electron-dl": "^3.0.0",
"electron-rebuild": "^1.10.0",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.17.1",
"fs": "0.0.1-security",
"html2canvas": "^1.0.0-rc.5",
"jquery": "^3.4.1",
"jquery.js": "0.0.2-security",
"jspdf": "^1.4.1",
"jspdf-autotable": "^3.3.1",
"jspdf-html2canvas": "^1.1.0",
"jszip": "^3.7.1",
"math.js": "^1.1.45",
"mathjs": "^6.6.5",
"moment": "^2.29.4",
"mssql": "^5.1.0",
"pdfkit": "^0.11.0",
"promise": "^8.1.0",
"request": "^2.88.2",
"round-to": "^5.0.0",
"sequelize": "^6.37.1",
"shelljs": "^0.8.4",
"sql.js": "^1.0.1",
"sqlite3": "^4.2.0",
"ted": "^0.1.1",
"tedious": "^6.3.0",
"xlsx-populate": "^1.21.0"
}
}`
code:
`const db_user = new Sequelize("RT","","1234",
{
dialect: "sqlite",
dialectModulePath: '@journeyapps/sqlcipher',
storage: path.join(__dirname,'RT.db'),
}
);
// SQLCipher config
db_user.query("PRAGMA cipher_compatibility = 4");
db_user.query("PRAGMA key = '1234'");
async function connectdb(){
try {
await db_user.authenticate();
return console.log('Connection has been established successfully.');
} catch (error) {
return console.error('Unable to connect to the database:', error);
}
}`