-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentService.py
More file actions
107 lines (91 loc) · 3.36 KB
/
studentService.py
File metadata and controls
107 lines (91 loc) · 3.36 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import db_util1 as dbutil
def createStudent():
print('DO YOU WANT TO CREATE NEW STUDENT?')
a = str(input('YES OR NO: '))
b = []
if a == 'yes' or a == 'Yes' or a == 'YES':
studentid = int(input('ID: '))
studentCount = dbutil.getStudetCount(studentid)
if studentCount != 1:
b.append(studentid)
b.append(str(input('NAME: ')))
age = int(input('AGE: '))
allSubjects = str(input('SUBJECT: '))
i = allSubjects.replace(',',':')
subjectCount = len(allSubjects.split(','))
if age >= 20 and subjectCount >= 2:
b.append(age)
b.append(i)
b.append(str(input('ADDRESS: ')))
print()
print()
x = tuple(b)
dbutil.inseartInToStudentDb(x)
print('USR HAS BEEN Successfull CREATED')
else:print('try again')
else:print('uer already exist')
else:print('Retry')
def studentFetchId():
print('DO YOU WANT TO READ NEW STUDENT?')
a = str(input('YES OR NO: '))
if a == 'yes' or a == 'Yes' or a == 'YES':
studentid = int(input('ID: '))
Sudentidlist = dbutil.fineIdStudentDb(studentid)
x = len(Sudentidlist)
if x == 1:
print('Id:',Sudentidlist[0][0],)
print('Name:', Sudentidlist[0][1])
print('Age:', Sudentidlist[0][2])
print('Subject:', Sudentidlist[0][3])
print('Address:', Sudentidlist[0][4])
else:print('this user not exist')
else:print('retry')
def updateStudentRecord():
print('Do you want to update the student record?')
a = str(input('YES OR NO: '))
b = []
age = ['AGE', 'age', 'Age']
subject = ['SUBJECT', 'subject', 'Subject', 'Sub', 'sub']
address = ['ADDRESS', 'address', 'Address', 'addr', 'Addr']
if a == 'yes' or a == 'Yes' or a == 'YES':
studentid = int(input('ID: '))
studentCount = dbutil.getStudetCount(studentid)
if studentCount == 1:
b.append(studentid)
typeofdata = str(input('What do you want to change?(Age,Sub.,Addr.): '))
if typeofdata in age:
b.append(str(input('Update Age: ')))
b.reverse()
dbutil.udateStudentAge(b)
print()
print('Updated')
if typeofdata in subject:
allsubject = str(input('Update Subject: '))
i = allsubject.replace(',',':')
b.append(i)
b.reverse()
dbutil.udateStudentSubject(b)
print()
print('Updated')
if typeofdata in address:
b.append(str(input('Update Address: ')))
b.reverse()
dbutil.udateStudentAddress(b)
print()
print('Updated')
else:
print('User not exist')
print('Creat New Student')
else:print('try again')
def deleteSudentRecord():
print('Do you want to delete the student Record?')
a = str(input('YES OR NO: '))
if a == 'yes' or a == 'Yes' or a == 'YES':
studentid = int(input('ID: '))
studentCount = dbutil.getStudetCount(studentid)
if studentCount == 1:
dbutil.deleteStudenRecord(studentid)
print('Student Record Deleted')
else:print('Record Unavailable')
if __name__ == '__main__':
deleteSudentRecord()