Delete Data from Table
We can use the Delete query to delete data from the table in MySQL.
Syntax:
DELETE FROM TABLE_NAME WHERE ATTRIBUTE_NAME = ATTRIBUTE_VALUE
Example: Delete Data from MySQL table using Python
Python3
# importing required libraries import mysql.connector dataBase = mysql.connector.connect( host = "localhost" , user = "user" , passwd = "password" , database = "gfg" ) # preparing a cursor object cursorObject = dataBase.cursor() query = "DELETE FROM STUDENT WHERE NAME = 'Ram'" cursorObject.execute(query) dataBase.commit() # disconnecting from server dataBase.close() |
Output:
Python MySQL
Python MySQL Connector is a Python driver that helps to integrate Python and MySQL. This Python MySQL library allows the conversion between Python and MySQL data types. MySQL Connector API is implemented using pure Python and does not require any third-party library.
This Python MySQL tutorial will help to learn how to use MySQL with Python from basics to advance, including all necessary functions and queries explained in detail with the help of good Python MySQL examples. So, let’s get started.