Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlite changes between 4.3 and 4.7
QtWS25 Last Chance

QSqlite changes between 4.3 and 4.7

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LKIM
    wrote on last edited by
    #1

    Hi All,

    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);
    #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).

    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.

    Thanks,
    Liron

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Felix
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LKIM
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved