pymysql module execute sql query using execute(method cursor execute('select from students'print('cursor rowcount'cursor rowcountprint('cursor description'cursor descriptionfetch all the rows and then iterate over the data data cursor fetchall(for row in datastudent_idnamesurnamesubjectemail row student student(student_idnamesurnamesubjectemailprint(studentdisconnect from server connection close(the output from this programfor the database created in the last is shown herecursor rowcount cursor description (('id' none false)('name' none false)('surname' none false)('subject' none false)('email' none false)student[ phoebe cooke animation pc@my com student[ gryff jones games grj@my com student[ adam fosh music af@my com student[ jasmine smith games js@my com student[ tom jones music tj@my com student[ james andrews games ja@my com inserting data to the database as well as reading data from database many applications also need to add new data to the database this is done via the dml (data manipulation languageinsert statement the process for this is very similar to running query against the database using select statementthat isyou need to make connectionobtain cursor object and execute the statement the one difference here is that you do not need to fetch the results