Frage

My team were previously using Qt 4.3 and are trying to update to the latest release (4.7.2).

Before we were using the qsqlite plugin, but this functionality has been moved into the main QSql component of Qt.

Now that we have upgraded, we're unable to read our old databases. This seems to be because when we created our tables, we created them like this:

CREATE TABLE [Characters] ([Id] INTEGER NOT NULL ON CONFLICT ROLLBACK PRIMARY KEY ON CONFLICT ROLLBACK AUTOINCREMENT UNIQUE ON CONFLICT ROLLBACK, [Project_Id] INTEGER NOT NULL ON CONFLICT ROLLBACK REFERENCES [Projects](Id) ON DELETE RESTRICT ON UPDATE RESTRICT ON INSERT RESTRICT, [CharacterName] VARCHAR(128) NOT NULL ON CONFLICT ROLLBACK UNIQUE ON CONFLICT ROLLBACK);

but ON INSERT RESTRICT is no longer valid.

I was able to remove that code and create new tables, but if I do myQSqlDatabase.tables() on one of the existing DBs, it returns zero.

I noticed by digging into the Qt code, that the prepare method has:

#if (SQLITE_VERSION_NUMBER >= 3003011)
    int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, 0);
#else
    int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, 0);
#endif

and we are entering the first if (sqlite3_prepare16_v2).

Should we be defining SQLITE_VERSION_NUMBER somewhere to be lower? Is there something else that we're doing wrong to prevent backwards compatibility?

Any help would be appreciated.

Thanks, Liron

War es hilfreich?

Lösung

sqlite as downloaded from the authors website comes with a command line program. If your database isn't compatible you can easily use it to export your data to a text file and load it into your new database.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top