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

Program19 (Py SQL Update Record)

The document provides a Python program that integrates SQL with Python using the MySQL module to update employee records based on a given employee number. It connects to a MySQL database, retrieves employee data, and allows the user to update the salary of the specified employee. The program includes user prompts for confirmation and displays updated records after the operation.

Uploaded by

jaisuryar116
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 views2 pages

Program19 (Py SQL Update Record)

The document provides a Python program that integrates SQL with Python using the MySQL module to update employee records based on a given employee number. It connects to a MySQL database, retrieves employee data, and allows the user to update the salary of the specified employee. The program includes user prompts for confirmation and displays updated records after the operation.

Uploaded by

jaisuryar116
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