Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QSQLQUERY can't execute "ALTER TABLE table_name DROP col_name
Forum Updated to NodeBB v4.3 + New Features

QSQLQUERY can't execute "ALTER TABLE table_name DROP col_name

Scheduled Pinned Locked Moved Solved Qt for Python
7 Posts 3 Posters 950 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.
  • C Offline
    C Offline
    Cedric.Niu
    wrote on last edited by
    #1

    I want to delete column from SQLite table, then I found an answer.

    5344f560-6394-4125-89e5-c8bc88065c06-image.png

    It is not convenient to create a temporary table,so I hope to use "DROP".

    But QSQLQUERY can't execute "ALTER TABLE test DROP test1".
    I guess the version of qsqlite is too low. How can I address this issue? Thanks !
    `6e2e2cb1-a69c-411d-afc5-37a5e541d853-image.png

    JonBJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #6

      ok, that is the reason then. Qt 5.15.1 comes with SQLite v3.32.3.

      (Z(:^

      C 1 Reply Last reply
      1
      • C Cedric.Niu

        I want to delete column from SQLite table, then I found an answer.

        5344f560-6394-4125-89e5-c8bc88065c06-image.png

        It is not convenient to create a temporary table,so I hope to use "DROP".

        But QSQLQUERY can't execute "ALTER TABLE test DROP test1".
        I guess the version of qsqlite is too low. How can I address this issue? Thanks !
        `6e2e2cb1-a69c-411d-afc5-37a5e541d853-image.png

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @Cedric-Niu
        Firstly your syntax, if it works at all, is wrong. You would (presumably) need ALTER TABLE test DROP COLUMN test1.

        Assuming that too fails, what would you like anyone here to say about SQLite that is not covered in the stackoverflow/other references? Do you think people here miraculously know more than these? Upgrade your SQLite to one which supports the DROP COLUMN statement, or use the workaround which you do not find "convenient". Or change database.

        C 1 Reply Last reply
        2
        • JonBJ JonB

          @Cedric-Niu
          Firstly your syntax, if it works at all, is wrong. You would (presumably) need ALTER TABLE test DROP COLUMN test1.

          Assuming that too fails, what would you like anyone here to say about SQLite that is not covered in the stackoverflow/other references? Do you think people here miraculously know more than these? Upgrade your SQLite to one which supports the DROP COLUMN statement, or use the workaround which you do not find "convenient". Or change database.

          C Offline
          C Offline
          Cedric.Niu
          wrote on last edited by
          #3

          @JonB Thanks a lot.

          ALTER TABLE test DROP COLUMN test1
          

          It is also wrong.
          `
          143dc4b5-c02a-41fd-b0f0-8abfb096f156-image.png
          In Qsqlquery it doesn't work, but it works in SQLite(3.35.0)

          ALTER TABLE test DROP test1
          

          I don't know how to upgrade qsqlite.dll. So I only create a new table.

          Thanks

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #4

            Which Qt version are you using? Qt is bundling it's own build of SQLite so if you are not on newest Qt, you may be using SQLite older than 3.35.

            (Z(:^

            C 1 Reply Last reply
            0
            • sierdzioS sierdzio

              Which Qt version are you using? Qt is bundling it's own build of SQLite so if you are not on newest Qt, you may be using SQLite older than 3.35.

              C Offline
              C Offline
              Cedric.Niu
              wrote on last edited by
              #5

              @sierdzio PYSIDE2 5.15.1

              Pyside6 may be using SQLite newer than 3.35...

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #6

                ok, that is the reason then. Qt 5.15.1 comes with SQLite v3.32.3.

                (Z(:^

                C 1 Reply Last reply
                1
                • sierdzioS sierdzio

                  ok, that is the reason then. Qt 5.15.1 comes with SQLite v3.32.3.

                  C Offline
                  C Offline
                  Cedric.Niu
                  wrote on last edited by
                  #7

                  @sierdzio Ok, thanks. I have tested. Pyside2 can't do it, Pyside6 can do it.

                  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