I have a question when updating from Python to sqlite3.

Asked 2 years ago, Updated 2 years ago, 65 views

1    def ComboNameChange(self, event):
2        ChangeName = self.combos1_2.GetValue()
3        for NameData in self.comboData2:
4            if NameData == self.combobind1_2:
5                self.cursor.execute('UPDATE CLINIC17 SET NAME1=?', (ChangeName, ))
6                self.conn.commit()

The example code above. I am making a program with wxpython module and I have a question I have a question.

1 Select a value in the combo box, clear it with the backspace, and press Enter to activate

2self.combos1_2.GetValue() After selecting the combo box, the changed name (value entered by the keyboard after pressing the backspace) is saved in the ChangeName variable.

3 self.comboData2 The (duple) name stored in the database is saved in NameData using a repeat statement.

4 If the value selected in the self.combobind1_2 combo box is the same as the NameData name

5 Changed ChangeName name (value) UPDATE CLINIC17 SET NAME1=?Change to column...

I have a question here. It works very well. UPDATE CLINIC17 SET NAME1=? In this part, NAME1=? Here are columns from NAME1 to 20 when creating a table. The code above only changes NAME 1, but what should I do to make it work from NAME 1 to 20?

xxx(i) next to the Bonnie column in Python sqlite3 guide.They use it like this.using len function Should I do it? Or create a counter variable and run for NameData in self.comboData2: If you increase the value by 1, the name column and the duple number will be the same... It's hard

sqlite3 python

2022-09-22 11:03

1 Answers

0    TEXT="UPDATE CLINIC17 SET NAME1"
1    def ComboNameChange(self, event):
2        ChangeName = self.combos1_2.GetValue()
3        for NameData in self.comboData2:
4            if NameData == self.combobind1_2:
                    for target in range(1,21):
                    TEXT_tmp=TEXT.replace('NAME1','NAME'+str(target))
5                self.cursor.execute(TEXT_tmp+'=?', (ChangeName, ))
6                self.conn.commit()


2022-09-22 11:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.