我按照这个 程序,并生成了一个数据库,该数据库是用密码保护的。sqlcipher. 然后我通过以下方式进行连接 sqlite3 语法。
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('path/to/database/file', (err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQlite database.');
});
var query = 'select COUNT(*) as count from table_name where column_name IS NOT NULL;';
db.serialize(function () {
db.all(query, function (err, rows) {
if (err) {
console.log(err);
}else{
console.log(rows);
}
});
});
我的期望是让查询被执行,但得到错误。 错误: SQLITE_NOTADB: file is not a database..我试过了,但没有找到任何解决方案。先谢谢你。
你需要提供你用于加密的密码。
pragma key='mypassword';
作为你的第一条语句,就在打开数据库之后。
加密数据库的整体思路是,你不应该只是 "让查询被执行",不是吗?