Python Forum
Mysql Workbench table not updated
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mysql Workbench table not updated
#1
My code:
(I want "pathology" table in MySQL Workbench to be updated when clicking on the "update" button.)
 def update(self):
            conn=mysql.connector.connect(host="localhost",user="root",password="root",database="pathology")
            my_cursor=conn.cursor()       
            my_cursor.execute("update pathology set receivedate=%s,patientname=%s,pathologynum=%s,gender=%s,age=%s,inspechospital=%s,casenum=%s,specimenclass=%s,bed=%s,diagnosis=%s,clinicaldiagnose=%s,inspecdoctor=%s,pathologydoctor=%s,sampledate=%s,reportdate=%s where num=%s",(
                                self.var_rec_date.get(),
                                self.var_patient_name.get(),
                                self.var_path_num.get(),
                                self.var_gender.get(),
                                self.var_age.get(),
                                self.var_sub_hospital.get(),
                                self.var_case_num.get(),
                                self.var_specimen_level.get(),
                                self.var_bed.get(),
                                self.var_diagnosis.get(),
                                str(contents),                                                                         
                                self.var_submit_doctor.get(),
                                self.var_simple_date.get(),
                                self.var_path_doc.get(),
                                self.var_report_date.get(),   
                                self.var_sys_num.get(),                
            ))
My "pathology report", you can see the "update" button.
[Image: 272befc6c8601453b6913ad067dd5f95.png]

"Successfully updated"
[Image: b21d61d49c0ba6492f1fa793a88a3130.png]

Here's my "pathology" in MySQL Workbench. The values in the "pathology" table aren't updated.
[Image: 89ad25108ef9a2e4755d3a3096b707c2.png]
Reply
#2
Perhaps you should commit the changes. Add "conn.commit()" after executing the update statement. Does that help?
buran likes this post
Reply
#3
(Feb-11-2023, 11:21 AM)ibreeden Wrote: Perhaps you should commit the changes. Add "conn.commit()" after executing the update statement. Does that help?

thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 692 Oct-03-2023, 10:25 PM
Last Post: lostintime
Photo How to select NULL and blank values from MySQL table into csv python300 9 2,456 Dec-27-2022, 09:43 PM
Last Post: deanhystad
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,137 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,183 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Creating table in MySQL db with decimal number issue dangermaus33 7 4,931 Nov-20-2020, 10:40 PM
Last Post: dangermaus33
  live updated json file Nyanpasu 2 2,241 Aug-22-2020, 04:41 PM
Last Post: Nyanpasu
  Multiple items of a matrix has been updated. Yoki91 4 2,327 May-19-2020, 06:29 PM
Last Post: Yoki91
  Load table from Oracle to MYSQL using python himupant94 0 1,654 May-12-2020, 04:50 PM
Last Post: himupant94
  Code import .CSV file to MySQL table rtakle 4 2,874 Apr-30-2020, 03:16 PM
Last Post: anbu23
  Mysql CREATE TABLE IF NOT EXISTS dynamic table name nisusavi 0 2,356 Apr-29-2020, 06:45 PM
Last Post: nisusavi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020