-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalumni_module.mysql
271 lines (267 loc) · 11 KB
/
alumni_module.mysql
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import mysql.connector
import os
import random
mydb = mysql.connector.connect(host = 'localhost', user = 'root', passwd = '') #password was intentionally omitted
mycursor = mydb.cursor()
if os.path.isfile('1.dat') == False:
f = open('1.dat','wb')
f.close()
mycursor.execute('Create database alumni_information_system')
mydb = mysql.connector.connect(host = 'localhost', user = 'root', passwd = 'Miluna30/04/2004',database='Alumni_information_system') #connecting to database
mycursor = mydb.cursor()
import app
if os.path.isfile('Three.dat') == False:
f = open('Three.dat','wb')
f.close()
mycursor.execute('create table alumni_login_table(Registration_No int(15) primary key, Full_Name varchar(30) not null, Username varchar(15) not null, password varchar(15) not null)')
mycursor.execute('create table alumni_information_table (Registration_No int(15) primary key, First_name varchar(30), Last_name varchar(30), login_password varchar(15), email_id varchar(15), Phone_no varchar(15), address varchar(50), occupation varchar(30), year_of_graduation varchar(5),stream varchar(20), Pass_year char(4),Qualification varchar(20),Current_position varchar(20), DOB varchar(15), city varchar(20), country varchar(20),employment varchar(20))')
mycursor.execute('create table teacher_information_table (Teacher_id int(15) primary key, First_name varchar(10), last_name varchar(10),login_password varchar(15),email_id varchar(15),Phone_no varchar(15),address varchar(50))')
mycursor.execute('create table retired_teacher_information_table(First_name varchar(10), last_name varchar(10), email_id varchar(15),phone_no varchar(15),address varchar(50))')
mycursor.execute('insert into alumni_login_table(registration_no,full_name,username,password)\
values(%d,"%s","%s",%d)'%(2,"Admin","Admin1",123))
mycursor.execute('insert into alumni_login_table(registration_no,full_name,username,password)\
values(%d,"%s","%s",%d)'%(1,"Student1","Stu1",771))
mycursor.execute('insert into alumni_login_table(registration_no,full_name,username,password)\
values(%d,"%s","%s",%d)'%(3,"Alumni1","Al1",913))
print('------------WELCOME to the ALUMNI INFORMATION SYSTEM------------')
print()
print('SIGN UP - enter 1')
print('LOGIN - enter 2')
print()
log = int(input('Enter your choice:'))
if log == 1:
print()
fname = input('Enter first name:')
lname = input('Enter last name:')
name = fname+' '+lname
nam = fname+lname
reg = random.randint(1,999999)
print('Enter 1 for student, 2 for staff, 3 for alumni')
print()
x = input('Enter:')
l = []
mycursor.execute('Select registration_no from alumni_login_table')
for i in mycursor:
l+=[i[0]]
while str(reg).startswith(x) == False or reg in l:
reg = random.randint(1,999999)
else:
print('Registration is:',reg)
passw = nam[3:-1] + str(reg)[len(str(reg))//2]
print('Password is:',passw)
use = name[0:len(nam)//2]
print('Username is:',use)
mycursor.execute('insert into alumni_login_table(registration_no,full_name,username,password)\
values(%d,"%s","%s","%s")'%(reg,name,use,passw))
mydb.commit()
print()
elif log == 2:
print('Please select one of the following:')
print()
print('• If you are a student- Enter 1')
print('• If you are a staff member- Enter 2')
print('• If you are an alumnus- Enter 3')
print()
choice = int(input('Enter your choice:'))
print()
if choice == 1:
print()
print('--LOGIN--')
user = input('Enter your username:')
passwd = input('Enter your password:')
print()
sec = app.login(user,passwd)
print()
if sec!=0:
print('MENU')
print()
print('1. Search for an alumni')
print('2. LOGOUT')
print()
while True:
x = int(input('Enter your choice:'))
print()
if x == 1:
app.alumnussearch()
print()
elif x == 2:
print()
print('Thank You! Logging out')
break
else:
print('Incorrect option! Enter a valid choice')
print()
elif choice == 2:
print()
print('--LOGIN--')
print()
user = input('Enter your username:')
passwd = input('Enter your password:')
print()
sec = app.stafflogin(user,passwd)
print()
if sec != 0:
print('MENU')
print()
print('1. Modify a table')
print('2. Remove a record from a table.')
print('3. Search for a certain student, alumnus or staff')
print('4. Display table records')
print('5. Insert into retired_teacher_information_table')
print('6. LOGOUT')
print()
while True:
x = int(input('Enter your choice:'))
print()
if x == 1:
print('Which table do you want to modify?')
print()
print('''1.Alumni login table\n
2.Teacher information table\n
3.Retired teacher information table''')
print()
while True:
y = int(input('Enter the number next to the desired table to be modified:'))
print()
if y == 1:
app.modifyregister()
print()
break
elif y == 2:
app.modifyteacher()
print()
break
elif y == 3:
app.modifyretire()
print()
break
else:
print('Incorrect option! Enter a valid option')
print()
elif x == 2:
print('From which table do you want to remove a record from?')
print()
print('''1.Alumni login table\n
2.Teacher information table to retired teacher information table\n
3.Retired teacher information table\n
4.Alumni_information_table''')
print()
while True:
y = int(input('Enter the number next to the desired table to be removed:'))
print()
if y == 1:
app.remove_login()
print()
break
elif y == 2:
app.remove_teacher()
print()
break
elif y == 3:
app.remove_retire()
print()
break
elif y == 4:
app.remove_alumni()
print()
break
else:
print('Enter valid option')
print()
elif x == 3:
print('From which table do you want to search for a record from?')
print()
print('''1.Alumni login table\n
2.Teacher information table to retired teacher information table\n
3.Retired teacher information table\n
4.Alumni_information_table''')
print()
while True:
y = int(input('Enter the number next to the desired table to be searched:'))
print()
if y == 1:
app.loginsearch()
print()
break
elif y == 2:
app.remove_teacher()
print()
break
elif y == 3:
app.remove_retire()
print()
break
elif y == 4:
app.alumnisearch()
print()
break
else:
print('Enter valid option')
print()
elif x == 4:
print()
app.display_table()
print()
elif x == 5:
print()
app.insert_retired()
print()
elif x == 6:
print()
print('Thank you! Logging out')
break
else:
print('Incorrect option! Enter a valid option.')
print()
elif choice == 3:
print()
print('--LOGIN--')
print()
user = input('Enter your username:')
passwd = input('Enter your password:')
print()
sec = app.alumnilogin(user,passwd)
print()
if sec != 0:
print('MENU')
print()
print('1. Register yourself')
print('2. modify your data')
print('3. Remove your data')
print('4. Search for a certain alumnus or staff')
print('5. LOGOUT')
print()
while True:
x = int(input('Enter your choice:'))
print()
if x == 1:
app.insertalumni()
print()
elif x == 2:
app.modifyalumni()
print()
elif x == 3:
app.remove_alumni()
print()
elif x == 4:
print('''Which table do you want to search?\n
1. Alumni information table\n
2.Teacher information table''')
print()
while True:
y = int(input('Enter your choice:'))
print()
if y == 1:
app.alumnussearch()
print()
break
elif y == 2:
app.staffsearch()
print()
break
elif x == 5:
print('Thank you')
break
else:
print('Enter a valid choice')
print()