pymysql insert static
Python insert Static Operation.
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() str2_query = "insert into teacher3 values(1,'aakash')" cur.execute(str2_query) conn.commit() print("data inserted successfully") conn.close()
Leave a Comment