Python MySQL Update Query:
(1) Update query is used to update existing records in the database. The following data is present in the database table as shown below.
We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it. |
(2) In this example, we update the fourth row of the employee_table. For this, we write the following query as shown below.
Note: We always need to call the connection’s commit method to write our changes out to the database. Otherwise, when the connection is closed, our changes may be lost. In fact, until we call the commit method, none of our updates may be visible from other database connections.
(3) Now open localhost/phpmyadmin in the browser and click on the employee database, you find the employee_table. After clicking on the employee table, you see that the fourth row will be updated as shown below. (Follow this blog for all steps “Create Table In MySQL Python“).
Comments (No)