inserting data to the database import pymysql open database connection connection pymysql connect('localhost''user''password''uni-database'prepare cursor object using cursor(method cursor connection cursor(tryexecute insert command cursor execute("insert into students (idnamesurnamesubjectemailvalues ( 'denise''byrne''history''db@my com')"commit the changes to the database connection commit(exceptsomething went wrong rollback the changes connection rollback(close the database connection connection close(the result of running this code is that the database is updated with seventh row for 'denise byrnethis can be seen in the mysql workbench if we look at the contents of the students tablethere are couple of points to note about this code example the first is that we have used the double quotes around the string defining the insert command-this is because double quotes string allows us to include single quotes within that string this is necessary as we need to quote any string values passed to the database (such as 'denise'the second thing to note is that by default the pymysql database interface requires the programmer to decide when to commit or rollback transaction transaction was introduced in the last as an atomic unit of work that must either be completed or as whole or rollback so that no changes are made howeverthe way in which we indicate that transaction is completed is by calling