Get all values from sqlquery.
-
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 valuesI'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
-
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 valuesI'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
@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) -
@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)@jsulm
I wrote:a = [Zest] b=a.append(Zest) print (b)but It takes none
Wheres I expect: ["value1", "value2", "value3"....]
-
@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)@jsulm Reading the values is ok, but I need put all into array. I have problem how to do it!
-
@jsulm
I wrote:a = [Zest] b=a.append(Zest) print (b)but It takes none
Wheres I expect: ["value1", "value2", "value3"....]
@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) -
Yes, creating array in while loop was a good idea!
[put the voice of hitting head on desk here] :-( link text