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. [Solved] SQLite: pragma foreign_key_check
Forum Updated to NodeBB v4.3 + New Features

[Solved] SQLite: pragma foreign_key_check

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.5k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    achronop
    wrote on 29 Apr 2014, 11:48 last edited by
    #1

    I try to execute a QSqlQuery for the following pragma command (sqlite) but it does not return the expected results.

    QSqlQuery q("pragma foreign_key_check")

    The expected result would be to return the 4 columns table with all foreign key constrains violations. I have entered in purpose some violations but it returns an empty record (q.size() == -1). From sqlite studio I am able to see the results of this commands. no through Qt though.

    Other pragma commands like "pragma foreign_key_list(tablename)" work fine.

    Can anyone explain why "pragma foreign_key_check" command does not return any result when it should?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      googie
      wrote on 29 Apr 2014, 20:32 last edited by
      #2

      Check if the SQLite driver in your Qt is 3.7.16 or higher, because that's the version in which this pragma was introduced. To check version execute query:

      SELECT sqlite_version()

      1 Reply Last reply
      0
      • A Offline
        A Offline
        achronop
        wrote on 30 Apr 2014, 11:03 last edited by
        #3

        Thank you googie!
        The problem was exactly that. I had driver version 3.6.19 and now I updated to 3.8.4.3 and the problem solved!

        Just for reference the q.size() is again -1 but the violations are returned correctly.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 30 Apr 2014, 19:58 last edited by
          #4

          Hi and welcome to devnet,

          IIRC, not all database drivers support returning query sizes. You can check with QSqlDriver::hasFeature(QSqlDriver::QuerySize);

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          29 Apr 2014, 11:48

          • Login

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