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. Number of query bindValues can't be more than 1000
Forum Updated to NodeBB v4.3 + New Features

Number of query bindValues can't be more than 1000

Scheduled Pinned Locked Moved General and Desktop
14 Posts 4 Posters 3.4k 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.
  • uralbashU uralbash

    Hello,

    I'm use query.prepare, query.bindValue and query.exec for insert value in sqlite table. Everything works well until the count of bindValue less or equal then 999, if it's 1000 or more sql query raise exception " Parameter count mismatch". Is this a bug and where I can find a description about these restrictions?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #3

    @uralbash Do you really need to have more than 64 columns in one table?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    uralbashU 1 Reply Last reply
    0
    • uralbashU Offline
      uralbashU Offline
      uralbash
      wrote on last edited by
      #4

      I know about limit in SQLite and I think that a different problem 'cause I'm trying to write a small query see example http://pastebin.com/8PNyC8F6 . It's 1000 bindValue query which raises error "Parameter count mismatch" if I run it from sqlitebrowser everything is ok and if I bind 999 values it also work ok. And also it does not matter what length of value I write "(0)" or "(99999999999999999999)" breaks every time when qty of bind value >= 1000.

      1 Reply Last reply
      0
      • jsulmJ jsulm

        @uralbash Do you really need to have more than 64 columns in one table?

        uralbashU Offline
        uralbashU Offline
        uralbash
        wrote on last edited by
        #5

        @jsulm I am using query generator that bindValue for all inserted row, for example INSERT INTO "foo_table" VALUE (foo, bar) (:foo1, bar1), (:foo2, bar2), (:foo3, bar3), ..., (:foo1000, bar1000) It is necessary for auto escaping quoted string.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #6

          In this case, if your driver supports it (db->driver()->hasFeature(QSqlDriver::BatchOperations)==true), you can use batch exec

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • uralbashU Offline
            uralbashU Offline
            uralbash
            wrote on last edited by
            #7

            @VRonin Unfortunately sqlite driver not support this feature

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #8

              Then I'd just execute multiple queries. The limit at 1000 is a limit of SQLite. the database treats multi line insert as compound select, the limit is 500 times 2 arguments per line = 1000

              Nothing to do with Qt

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              uralbashU 1 Reply Last reply
              2
              • VRoninV VRonin

                Then I'd just execute multiple queries. The limit at 1000 is a limit of SQLite. the database treats multi line insert as compound select, the limit is 500 times 2 arguments per line = 1000

                Nothing to do with Qt

                uralbashU Offline
                uralbashU Offline
                uralbash
                wrote on last edited by
                #9

                @VRonin This may not be a limitation of sqlite because I can execute this query with sqlitebrowser and query.exec() with raw query but not with bindValue

                VRoninV 1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #10

                  Yet again, what's stopping you from simply running multiple queries?

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  uralbashU 1 Reply Last reply
                  0
                  • VRoninV VRonin

                    Yet again, what's stopping you from simply running multiple queries?

                    uralbashU Offline
                    uralbashU Offline
                    uralbash
                    wrote on last edited by
                    #11

                    @VRonin That's what I'm doing now
                    insert record one by one into the table, but it is extremely slow

                    1 Reply Last reply
                    0
                    • VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #12

                      no need to do 1 by one, split it into chunks of 998 parameters

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      0
                      • uralbashU Offline
                        uralbashU Offline
                        uralbash
                        wrote on last edited by
                        #13

                        yes of course I do, just I want to understand why you can not bind more then 999 value?

                        1 Reply Last reply
                        0
                        • uralbashU uralbash

                          @VRonin This may not be a limitation of sqlite because I can execute this query with sqlitebrowser and query.exec() with raw query but not with bindValue

                          VRoninV Offline
                          VRoninV Offline
                          VRonin
                          wrote on last edited by
                          #14

                          @uralbash said in Number of query bindValues can't be more than 1000:

                          I can execute this query with [...] raw query but not with bindValue

                          You can build the raw query by hand anyway using QSqlDriver::formatValue to prevent injection

                          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                          ~Napoleon Bonaparte

                          On a crusade to banish setIndexWidget() from the holy land of Qt

                          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