Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Get all values from sqlquery.
Forum Updated to NodeBB v4.3 + New Features

Get all values from sqlquery.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 2.5k 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.
  • Karoluss96K Offline
    Karoluss96K Offline
    Karoluss96
    wrote on last edited by
    #1

    Hie everyone,

    I don't know how to take all values from query.record().value and put into python's [] table.

    Current begin of code looks that:

    query.exec_("SELECT * FROM avtr")#do dokończenia 
            while query.next():
                 Zest=str(query.record().value("NAME"))#it takes only one value
                 self.dlg.comboBox_6.addItem(Zest)
                 Zap = str(query.record().value("ANS"))
                 a = [Zest]#... to table in which I must add rest of record values
    

    I've tried some version with apped or join, but none of the works.

    I need it put future comparing value in table to combobox_6.currentText.

    Thanks for help

    PS. I watched a lot in this forum, but I didn't find the same problem with that

    jsulmJ 1 Reply Last reply
    0
    • Karoluss96K Karoluss96

      Hie everyone,

      I don't know how to take all values from query.record().value and put into python's [] table.

      Current begin of code looks that:

      query.exec_("SELECT * FROM avtr")#do dokończenia 
              while query.next():
                   Zest=str(query.record().value("NAME"))#it takes only one value
                   self.dlg.comboBox_6.addItem(Zest)
                   Zap = str(query.record().value("ANS"))
                   a = [Zest]#... to table in which I must add rest of record values
      

      I've tried some version with apped or join, but none of the works.

      I need it put future comparing value in table to combobox_6.currentText.

      Thanks for help

      PS. I watched a lot in this forum, but I didn't find the same problem with that

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

      @Karoluss96 said in Get all values from sqlquery.:

      [] table

      [] is an array in Python, not table.
      I don't understand the problem. You're already reading the values from the query using .vale() - so what exactly is your problem?
      If you want to append to that [] array then do it using append:

      a.append(Zest)
      

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

      Karoluss96K 2 Replies Last reply
      0
      • jsulmJ jsulm

        @Karoluss96 said in Get all values from sqlquery.:

        [] table

        [] is an array in Python, not table.
        I don't understand the problem. You're already reading the values from the query using .vale() - so what exactly is your problem?
        If you want to append to that [] array then do it using append:

        a.append(Zest)
        
        Karoluss96K Offline
        Karoluss96K Offline
        Karoluss96
        wrote on last edited by
        #3

        @jsulm
        I wrote:

        a = [Zest]
        b=a.append(Zest)
        print (b)
        

        but It takes none

        Wheres I expect: ["value1", "value2", "value3"....]

        jsulmJ 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Karoluss96 said in Get all values from sqlquery.:

          [] table

          [] is an array in Python, not table.
          I don't understand the problem. You're already reading the values from the query using .vale() - so what exactly is your problem?
          If you want to append to that [] array then do it using append:

          a.append(Zest)
          
          Karoluss96K Offline
          Karoluss96K Offline
          Karoluss96
          wrote on last edited by
          #4

          @jsulm Reading the values is ok, but I need put all into array. I have problem how to do it!

          1 Reply Last reply
          0
          • Karoluss96K Karoluss96

            @jsulm
            I wrote:

            a = [Zest]
            b=a.append(Zest)
            print (b)
            

            but It takes none

            Wheres I expect: ["value1", "value2", "value3"....]

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

            @Karoluss96 said in Get all values from sqlquery.:

            b=a.append(Zest)

            Please learn Python!
            The line above does not make any sense!
            It is really basic stuff:

            a=[]
            while query.next():
                         Zest=str(query.record().value("NAME"))#it takes only one value
                         self.dlg.comboBox_6.addItem(Zest)
                         Zap = str(query.record().value("ANS"))
                         a.append(Zest)
                         a.append(Zap)
            

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

            1 Reply Last reply
            0
            • Karoluss96K Offline
              Karoluss96K Offline
              Karoluss96
              wrote on last edited by Karoluss96
              #6

              Yes, creating array in while loop was a good idea!

              [put the voice of hitting head on desk here] :-( link text

              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