35.7 Delete From By
Delete Record You can delete records from an existing table by using the “DELETE FROM” statement: Example Delete any record where the address is “Mountain 21”:import mysql.connectormydb = mysql.connector.connect( host=”localhost”, user=”yourusername“, password=”yourpassword“, database=”mydatabase”)mycursor = mydb.cursor()sql = “DELETE FROM customers WHERE address = ‘Mountain 21′”mycursor.execute(sql)mydb.commit()print(mycursor.rowcount, “record(s) deleted”) Output:C:\Users\My Name>python demo_mysql_delete.py1 record(s) deleted Important!: Notice the statement: mydb.commit(). It is required to make the… Read More »
