Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSqlite changes between 4.3 and 4.7
LKIM last edited by
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 ON DELETE RESTRICT ON UPDATE RESTRICT ON INSERT RESTRICT,
[CharacterName] VARCHAR(128) NOT NULL ON CONFLICT ROLLBACK UNIQUE ON CONFLICT ROLLBACK);@
but it seems that ON INSERT RESTRICT is not valid.
If I remove that line, I can create new tables, but if I do myQSqlDatabase.tables() [or anything else] 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);
int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, 0);
and we are entering the first if (sqlite3_prepare16_v2).
I don't think it should have anything do to with the SQLITE_VERSION_NUMBER because that is an sqlite value, and we are able to open the DB fine in other sqlite viewer, just not with our Qt code.
Is there something else that we're doing wrong to prevent backwards compatibility? Has something changed that would prevent qt from reading this?
Any help would be appreciated.
Felix last edited by
i dont know, but could it be that your Database isnt a Sqlite 3 Database? then you might have to register the Database with QSQLITE2 as type to get the older version since QSQLITE as database type uses an Sqlite v3 Database. But im not sure, its just a guess.
LKIM last edited by
Unfortunately, it is for sure an sqlite3 db. All the tools I'm using to look into the db are treating it as an sqlite3 db.