Codied To Clipboard !
Home > Notes > pymysql
here everything will be same , expect we are not taking anything from the database. Rather we are putting the data to the database. commit() Method. This method sends a COMMIT statement to the MySQL server, committing the current transaction. Since by default Connector/Python does not autocommit, it is important to call this method after every transaction that modifies data for tables that use transactional storage engines
import pymysql conn = pymysql.connect( host='localhost', user='root', password="12345", db='sakila', ) cur = conn.cursor() str1_query = "update student SET name='piyush' WHERE id=14;" cur.execute(str1_query) conn.commit() print("updated successfully ") conn.close()