0% found this document useful (0 votes)
3 views2 pages

Program19 (Py SQL Update Record)

This Python program connects to a MySQL database to update employee records based on a provided employee number. It allows users to search for an employee, confirm the update, and modify the salary if desired. The program also provides an option to continue updating more records after each operation.

Uploaded by

kujan1465
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)
3 views2 pages

Program19 (Py SQL Update Record)

This Python program connects to a MySQL database to update employee records based on a provided employee number. It allows users to search for an employee, confirm the update, and modify the salary if desired. The program also provides an option to continue updating more records after each operation.

Uploaded by

kujan1465
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 update the employee record of entered


empno.'''
[Link]
con=[Link](host='localhost',user='root',
password='admin',database='geetha')
cur=[Link]()
print("EMPLOYEE SEARCHING FORM")
ans='y'
[Link]()=='y':
eno=input("Enter Employee Number to be updated:")
query="select * from employee where eno={}".format(eno)
[Link](query)
result=[Link]()
[Link]==0:
print("Sorry!Empno not found")
else :
print("%12s"%"EMPNO","%20s"%"NAME","%15s"%"Esal")
for row in result:
print("%10s"%row[0],"%23s"%row[1],"%15s"%row[2])
choice=input("\nAre you sure you want to update?(Y):")
[Link]()=='y':
print("==You can update details==")
d=input("Enter new salary:")
if d=="":
d=row[2]
query="update employee set Esal={} where eno={}".format(d,eno)
[Link](query)
[Link]()
print("Record Updated")
ans=input("Do you want to update more?(y):")
query="select * from employee"
[Link](query)
for i in cur:
print(i)
OUTPUT :

You might also like