pymysql module the commit(method on the database connection in turn we can indicate that we want to rollback the current transaction by calling rollback(in either caseonce the method has been invoked new transaction is started for any further database activity in the above code we have used try block to ensure that if everything succeedswe will commit the changes madebut if an exception is thrown (of any kindwe will rollback the transaction--this is common pattern updating data in the database if we are able to insert new data into the databasewe may also want to update the data in databasefor example to correct some information this is done using the update statement which must indicate which existing row is being updated as well as what the new data should be import pymysql open database connection connection pymysql connect('localhost''user''password''uni-database'prepare cursor object using cursor(method cursor connection cursor(tryexecute update command cursor execute("update students set email 'denise@my comwhere id "commit the changes to the database connection commit(exceptrollback the changes if an exception error connection rollback(close the database connection connection close(in this example we are updating the student with id such that their email address will be changed to 'denise@my comthis can be verified by examining the contents of the students table in the mysql workbench