Database is locked. Unable to fetch row in "DETACH DATABASE..."



  • In my restless dreams I see this code:

    bool DatabaseManager::saveEncryptedDatabase(const QString &path, const QString &password)
    {
        QSqlQuery q;
    
        q.exec(QString("ATTACH DATABASE '%1' AS encrypted KEY '%2'").arg(path, password));
        Utils::handleSqlError(q);
        q.exec(QString("SELECT sqlcipher_export('encrypted')"));
        Utils::handleSqlError(q);
        q.exec("DETACH DATABASE encrypted");
        Utils::handleSqlError(q);
        return true;
    }
    

    Where Utils::handleSqlError is printing error if any occured.
    Result:

    "SQL Query Error: database encrypted is locked Unable to fetch row in\nDETACH DATABASE encrypted"
    

    I have even delayed it to timer and tried to detach every 250ms. No luck. I've tried with transactions. Still nothing though.
    I've got dandruff on my head.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.