Skip to content

Commit 490e3f7

Browse files
committed
fixed many bugs
1 parent bc9925a commit 490e3f7

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

editemployee.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def f2():
160160
first_name=input("Enter first name (max 15 char): ")
161161
if len(first_name)<= 15:
162162
try:
163-
cur.execute("update employees set first_name={} where emp_no={}".format(first_name,emp_no))
163+
cur.execute("update employees set first_name='{}' where emp_no={}".format(first_name,emp_no))
164164
conn.commit()
165165
except mysql.connector.Error as err:
166166
print(err.msg)
@@ -177,7 +177,7 @@ def f2():
177177
last_name=input("Enter last name (max 15 char): ")
178178
if len(last_name)<= 15:
179179
try:
180-
cur.execute("update employees set last_name={} where emp_no={}".format(last_name,emp_no))
180+
cur.execute("update employees set last_name='{}' where emp_no={}".format(last_name,emp_no))
181181
conn.commit()
182182
except mysql.connector.Error as err:
183183
print(err.msg)
@@ -202,7 +202,7 @@ def f2():
202202
print("-----------Value addition was unsuccessful!!!!-------------")
203203
break
204204
else:
205-
print("Updated first name...")
205+
print("Updated gender...")
206206
break
207207

208208
elif a=='2':
@@ -215,7 +215,7 @@ def f2():
215215
print("-----------Value addition was unsuccessful!!!!-------------")
216216
break
217217
else:
218-
print("Updated first name...")
218+
print("Updated gender...")
219219
break
220220

221221
else:

fireemployee.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ def ap2():
2222
else:
2323
print("Maximum length is 5!")
2424

25-
query="delete from employees,empass where emp_no = {}".format(emp_no)
25+
query="delete from employees where emp_no = {}".format(emp_no)
26+
query2="delete from empass where emp_no = {}".format(emp_no)
2627
cur.execute("select emp_no from employees")
2728
record=cur.fetchall()
2829
changed=False
2930
for r in record:
3031
if r[0]==emp_no:
3132
try:
33+
cur.execute(query2)
34+
conn.commit()
3235
cur.execute(query)
3336
conn.commit()
3437
changed=True

hireemployee.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,14 @@ def ap1():
183183
print("Values added successfully!!")
184184
while True:
185185
password=input("Enter employee login password(max 8 characters, min 4): ")
186-
if len(password)>8:
186+
lp=len(password)
187+
if lp>8:
187188
print("Max 8 characters only.")
188-
elif len(password)<4:
189+
elif lp<4:
189190
print("Minimum 4 characters to be entered.")
190191
else:
191192
try:
192-
cur.execute("INSERT INTO empass values({},LPAD({},{},'0')".format(emp_no,password,len(password)))
193+
cur.execute("INSERT INTO empass values({},LPAD({},{},'0'))".format(emp_no,password,lp))
193194
query.commit()
194195
except mysql.connector.Error as err:
195196
print(err.msg)

main.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
import check
33
import accounttype
44
while True:
5-
if not check.check():
6-
accounttype.acctype()
5+
print("1.Continue")
6+
print("2.Quit")
7+
a=input("Enter your choice(1,2): ")
8+
if a == "1":
9+
if not check.check():
10+
accounttype.acctype()
11+
break
12+
else:
13+
setup.setup()
14+
elif a == "2":
15+
print("Shutting down the program")
716
break
817
else:
9-
setup.setup()
18+
print("Wrong input.")

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def querycheck():
139139
try:
140140
print("Creating table {}: ".format(table_name), end='')
141141
cursor.execute(table_description)
142+
existing+=1
142143
except mysql.connector.Error as err:
143144
if err.errno == errorcode.ER_TABLE_EXISTS_ERROR:
144145
print("already exists.")
@@ -147,7 +148,10 @@ def querycheck():
147148
print(err.msg())
148149
else:
149150
print("OK")
150-
ans=True
151+
if existing==7:
152+
with open("firsttime.txt","w") as f:
153+
f.write("False")
154+
ans=True
151155

152156
if not ans:
153157
print("There was a problem in connection")
@@ -183,8 +187,6 @@ def setup():
183187
if ans2=="1":
184188
mysqlsetup()
185189
if existing==7:
186-
with open("firsttime.txt","w") as f:
187-
f.write("False")
188190
continue
189191
if ans2=="2":
190192
print("\nThis is under development :). Please use mysql till then...")

showemployee.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ def ap4():
1010
cur=conn.cursor()
1111
cur.execute("select * from employees")
1212
results=cur.fetchall()
13-
print("---------------------------------------------------------------------------------------")
13+
print("+---------+-------------+------------------+------------------+---------+-------------+")
1414
print("|","%7s"%"EMP_NO","|","%11s"%"BIRTH_DATE","|","%16s"%"FIRST_NAME","|","%16s"%"LAST_NAME","|","%7s"%"GENDER","|","%11s"%"HIRE_DATE","|")
1515
for row in results:
16-
print("---------------------------------------------------------------------------------------")
16+
print("+---------+-------------+------------------+------------------+---------+-------------+")
1717
print("|","%7s"%row[0],"|","%11s"%row[1],"|","%16s"%row[2],"|","%16s"%row[3],"|","%7s"%row[4],"|","%11s"%row[5],"|")
1818
cur.close()
1919
conn.close()
20-
print("---------------------------------------------------------------------------------------")
20+
print("+---------+-------------+------------------+------------------+---------+-------------+")

0 commit comments

Comments
 (0)