-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram18.py
More file actions
25 lines (20 loc) · 749 Bytes
/
Program18.py
File metadata and controls
25 lines (20 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import mysql.connector as mycon
con = mycon.connect(host='127.0.0.1', user='root', password="admin", database="company")
cur = con.cursor()
print("#" * 40)
print("EMPLOYEE SEARCHING FORM")
print("#" * 40)
print("\n\n")
ans = 'y'
while ans.lower() == 'y':
eno = int(input("ENTER EMPNO TO SEARCH: "))
query = "SELECT * FROM employee WHERE empno={}".format(eno)
cur.execute(query)
result = cur.fetchall()
if cur.rowcount == 0:
print("Sorry! Empno not found.")
else:
print("%10s" % "EMPNO", "%20s" % "NAME", "%15s" % "DEPARTMENT", "%10s" % "SALARY")
for row in result:
print("%10s" % row[0], "%20s" % row[1], "%15s" % row[2], "%10s" % row[3])
ans = input("SEARCH MORE (Y): ")