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

Program18 (Py SQL Search Record)

The document provides a Python program that integrates SQL using the MYSQL module to search for an employee number in the 'employee' table. If the employee number is found, it displays the corresponding record; if not, it shows an appropriate message. The program continues to prompt the user for additional searches until they choose to stop.

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

Program18 (Py SQL Search Record)

The document provides a Python program that integrates SQL using the MYSQL module to search for an employee number in the 'employee' table. If the employee number is found, it displays the corresponding record; if not, it shows an appropriate message. The program continues to prompt the user for additional searches until they choose to stop.

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 search an employee


number in table employee and display record, if empno not found display appropriate message '''

Coding :

[Link] as mycon
con=[Link](host='localhost',user='root',password="admin",database="employee")
cur=[Link]()
ans='y'
[Link]()=='y':
eno1=int(input("ENTER EMPNO TO SEARCH:"))
query="select * from EMPLOYEE where eno={}".format(eno1)
[Link](query)
result=[Link]()
[Link]==0:
print("Sorry!empno not found")
else:
print("%10s"%"ENO","%20s"%"ENAME","%15s"%"ESCAL")
for row in result:
print("%10s"%row[0],"%20s"%row[1],"%15s"%row[2])
ans=input("SEARCH MORE(y):")

OUTPUT:

You might also like