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. "database table is locked Unable to fetch row"

"database table is locked Unable to fetch row"

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 4.0k 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
    Chrisw01
    wrote on last edited by
    #1

    Hello, I seem to be having issues with QSql.

    I am using QT 5.7 with mingw 32 compiler. When I try to drop a database table sql.exec() Return false and I receive the following error in lastError()->text(); "database table is locked Unable to fetch row".

    My SQL to delete the table is

    bool result = sql.exec("drop table SYSTEM_PROPERTIES"); // Always returns false and sets the above error.
    

    I can execute the above sql statement in a database manager without failure however.

    Thanks for any light you can shed on the matter.

    Chris--

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

      Hi,

      How many threads do you have in your application ?

      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
      • C Offline
        C Offline
        Chrisw01
        wrote on last edited by
        #3

        Hi, not creating any threads so I assume the answer is just the main one.

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Any pending request on that table ?

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

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            Any pending request on that table ?

            C Offline
            C Offline
            Chrisw01
            wrote on last edited by
            #5

            @SGaist None that I know of, in fact I can make that the first call right after the database is opened and it fails. I am going to install the latest version of QT and see if the problem goes away. I'll post the results when this is completed.

            Thanks..

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What backend are you using ? MySQL, PostgreSQL ? SQLite ?

              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
              • C Offline
                C Offline
                Chrisw01
                wrote on last edited by
                #7

                MySQL, but I found the problem, in my code I call select * from a database but I only wanted to get the first entry of the database so instead of letting the sql statement finish with a while(sql.next()) I called if(sql.next()) then processed my data thus not allowing sql to finish. As soon as I added sql.finish() my problem went away. What I don't understand is the select I was calling was on a different table than the one I Was trying to work with.

                Anyways, I'm in the process of updating all of my code to call sql.finish() on all sql statements.

                Thanks for your help on this.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  If you only want the first entry, why not use the LIMIT keyword with your query ? That way to don't have to resort to workaround like you are doing.

                  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
                  • C Offline
                    C Offline
                    Chrisw01
                    wrote on last edited by
                    #9

                    That's a good idea, thanks.

                    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