Hello everyone,
Greetings from Brazil! I'm trying to navigate through a MySQL database using pyMySQL and a GUI form to display the data, but when I press the 'Previous' button, for example, it prints the correct row number in the console, but the form doesn't display the previous record. Any ideas on what I am doing wrong?
This is what I have tried:
Best regards and stay well.
Greetings from Brazil! I'm trying to navigate through a MySQL database using pyMySQL and a GUI form to display the data, but when I press the 'Previous' button, for example, it prints the correct row number in the console, but the form doesn't display the previous record. Any ideas on what I am doing wrong?
This is what I have tried:
def ShowPrevious(self):
global rowNo
sql = "SELECT @row_no AS row_number, name, email, pwd, market FROM users WHERE (@row_no:=%s) ORDER BY name"
cur.execute(sql, rowNo)
row = cur.fetchone()
if rowNo <= cur.rowcount:
print("Row", rowNo, "is the first record.")
elif row:
ui.lineEdit_name.setText(row[1])
ui.lineEdit_email.setText(row[2])
ui.lineEdit_pwd.setText(row[3])
ui.lineEdit_market.setText(row[4])
rowNo -= 1
print(rowNo)
else:
rowNo += 1Thank you very much for your time and help. I really appreciate it.Best regards and stay well.
