Program:14
#14 #update all records #to display all records from a table #select command import mysql.connector from mysql.connector import Error con=None try: con = mysql.connector.connect(host='localhost',user='root', password='ct',database='student1') if(con.is_connected()==True): print("connected") db=con.cursor() sql="update stud set per=(total*100)/500" db.execute(sql) sql="select * from stud" db.execute(sql) res = db.fetchall() for x in res: print(x) con.commit(); except Error as e: print(e) finally: if con is not None and con.is_connected(): con.close() print("Connection closed")