QtCipherSqlitePlugin
QtCipherSqlitePlugin copied to clipboard
Password update is not working!
- How to update new password for my database?
My code is:
checkDb = QSqlDatabase::addDatabase("SQLITECIPHER");
checkDb.setDatabaseName("test.db");
checkDb.setPassword("test");
if (!checkDb.open()) {
qDebug() << "Can not open Db!" << checkDb.lastError().driverText();
}
else {
qDebug() << "try to change password";
QString strNew;
checkDb.setConnectOptions("QSQLITE_UPDATE_KEY=newtest");
qDebug() << checkDb.lastError().driverText();
}
checkDb.close();
Password update is not working. I can not change my db password. How Can I fix it?
Same problem updating password. Why is this issue submitted in Apr, and now in Oct it still has no reply?
Sorry for no reply for such a long time.
I think you misunderstand connectOptions. connectOptions should be set before QSqlDatabase::open(). You could think it is the options for connecting (opening) the database. So your code will not work because you set connectOptions after opening the database. Please check the following code:
QSqlDatabase dbconn = QSqlDatabase::addDatabase("SQLITECIPHER");
dbconn.setDatabaseName("test_c.db");
dbconn.setPassword("test");
dbconn.setConnectOptions("QSQLITE_UPDATE_KEY=newtest");
if (!dbconn.open()) {
qDebug() << "Can not open Db!" << dbconn.lastError().driverText();
} else {
qDebug() << "Password changed";
}
dbconn.close();