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. SQLite and PRAGMA

SQLite and PRAGMA

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • C Offline
    C Offline
    chocard
    wrote on last edited by
    #1

    Hi,

    I have a little problem with SQLite and PRAGMA.
    In the main after the database connection I set the PRAGMA foreign_keys to ON. If I do a request just after the value is at '1'.

    But in another class if I do the same request, foreign_keys is at '0'.
    I do a QSqlQuery q(QSqlDatabase::database()) so it's the same connection than in the main so I don't understand what is the problem.
    I must do the "PRAGMA foreign_keys=ON" at each request ? The value in not keep for the connection ?

    Thanks for your help
    Chocard

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      did You try with no
      a QSqlQuery q(QSqlDatabase::database())
      as it normally uses the default connection when no db is given.
      a QSqlQuery q;

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chocard
        wrote on last edited by
        #3

        Thank mrjj.
        After remove 'QSqlDatabase::database()' I find the problem (the database was close in other function).

        1 Reply Last reply
        2

        • Login

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