Python MySQL Delete
The DELETE FROM statement is used to delete a specific record from the table. Here, we must impose a condition using WHERE clause otherwise all the records from the table will be removed.
MySQL Delete
The following SQL query is used to delete the employee detail whose id is 110 from the table.
Copied
delete from Employee where id = 110
Python MySQL Delete Operation Example
Copied
import mysql.connector
myconn = mysql.connector.connect(host = "localhost", user = "root",password = "naveen",database = "PythonDB")
cur = myconn.cursor()
try:
cur.execute("delete from Employee where id = 110")
myconn.commit()
except:
myconn.rollback()
myconn.close()