Using the SQL UPDATE command
This recipe will use the code from the previous recipe, Using the SQL INSERT command, explain it in more detail, and then extend the code to update our data.
In order to update the data that we previously inserted into our MySQL database tables, we use the SQL UPDATE
command.
Getting ready
This recipe builds on the previous recipe, Using the SQL INSERT command, so read and study the previous recipe in order to follow the coding in this recipe, where we modify the existing data.
How to do it…
First, we will display the data to be modified by running the following Python to MySQL command:
import MySQLdb as mysql import Ch07_Code.GuiDBConfig as guiConf class MySQL(): # class variable GUIDB = 'GuiDB' #------------------------------------------------------ def showData(self): # connect to MySQL conn, cursor = self.connect() self.useGuiDB(cursor) # execute command cursor.execute("SELECT * FROM...