KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Science

Write a program to delete the employee record whose name is read from keyboard at execution time.

Python MySQL

2 Likes

Answer

import mysql.connector
mydb = mysql.connector.connect(host = "localhost", user = "root", passwd = "tiger", database = "School")
mycursor = mydb.cursor()
employee_name = input("Enter the name of the employee to delete: ")
mycursor.execute("DELETE FROM employee WHERE ENAME = %s", (employee_name,))
print(mycursor.rowcount, "Record Deleted")
Output
Enter the name of the employee to delete: RAJESH
1 Record Deleted

Answered By

3 Likes


Related Questions