0% found this document useful (0 votes)
2 views1 page

Program20 (Py SQL Delete A Record)

This Python program connects to a MySQL database to delete an employee record based on the entered employee number (empno). It retrieves and displays employee records, prompts the user for confirmation before deletion, and updates the database accordingly. The program continues to allow the user to delete more records until they choose to exit.

Uploaded by

lakshin1226
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Program20 (Py SQL Delete A Record)

This Python program connects to a MySQL database to delete an employee record based on the entered employee number (empno). It retrieves and displays employee records, prompts the user for confirmation before deletion, and updates the database accordingly. The program continues to allow the user to delete more records until they choose to exit.

Uploaded by

lakshin1226
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

'''Write a python program to integrate SQL with python

by importing the MYSQL module to delete the employee record of entered empno.'''
[Link]
con=[Link](host='localhost',user='root',
password='admin',database='geetha')
cur=[Link]()
print("EMPLOYEE DELETION FORM")
query="select * from employee"
[Link](query)
data=[Link]()
for i in data:
print(i)
ans='y'
[Link]()=='y':
eno=int(input("Enter Empno to delete:"))
query="select * from employee where eno={}".format(eno)
[Link](query)
result=[Link]()
[Link]==0:
print("Sorry!Empno not found")
else :
print("%10s"%"EMPNO","%20s"%"NAME","%10s"%"SALARY")
for row in result:
print("%10s"%row[0],"%20s"%row[1],"%15s"%row[2])
choice=input("\n##Are you sure you want to delete?(Y):")
[Link]()=='y':

query="delete from employee where eno={}" .format(eno)


[Link](query)
[Link]()
print("===Record deleted successfully!===")
query="select * from employee"
[Link](query)
data=[Link]()
for i in data:
print(i)
ans=input("DELETE MORE?(y):")

OUTPUT :

You might also like