[SOLVED]Function executing an action that is not there (???)
-
Hello everyone,
I have a rather strange problem. My application has a pushButton conected to a function. That function should fetch data from one lineEdit, query the SQLite database, and update an integer in database from 0 to 1 for name written into lineEdit. Here is the connection:
@QtCore.QObject.connect(self.ui.buttonArchive, QtCore.SIGNAL("clicked()"), self.archive)@
original function :
@def archive(self):
name = (str(self.ui.lineName.text()).upper())
if name:
with con:
cur = con.cursor()
reply = QtGui.QMessageBox.question(self, 'Archive',
"Are you sure? ", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
cur.execute('UPDATE cases SET archived = 1 WHERE name =?',[name])@Problem with the above function was that it always executed the query, even thou I press NO. So I changed the code.
This is the altered code. This one SHOULD NOT update the said integer, it should only print the name from database:
@def archive(self):
tempname = (str(self.ui.lineName.text()).upper())
if temname:
with con:
cur = con.cursor()
reply = QtGui.QMessageBox.question(self, 'Archive',
"Are you sure? ", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
cur.execute('SELECT name FROM cases WHERE name = ?',[tempname])
ime = cur.fetchone()
print(ime)@however...IT STILL UPDATES the integer in the database. It prints the name if I click YES, and updates the integer no matter what I press. I have removed all from pycache dir, moved the code to another dir, changed the names of functions, modules...and it always misbehaves.