demo_mysql_delete.py:
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="myusername", passwd="mypassword", database="mydatabase" ) mycursor = mydb.cursor() sql = "DELETE FROM customers WHERE address = 'Mountain 21'" mycursor.execute(sql) mydb.commit() print(mycursor.rowcount, "record(s) deleted")
C:\Users\My Name>python demo_mysql_delete.py
1 record(s) deleted