-
Notifications
You must be signed in to change notification settings - Fork 0
/
college management system.py
105 lines (90 loc) · 3.44 KB
/
college management system.py
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
import mysql.connector as mysql
db = mysql.connect(host="localhost", user="root", password="#b2a1l12a1#", database="college")
command_handler = db.cursor(buffered=True)
def admin_session():
while 1:
print("")
print("Admin Menu")
print("1. Register new Student")
print("2. Register new Teacher")
print("3. Delete Existing Student")
print("4. Delete Exixting Teacher")
print("5. Logout")
User_option = input(str("Option : "))
if User_option == "1":
print("")
print("Register New Student")
username = input(str("Student username: "))
password = input(str("Student password : "))
query_vals = (username, password)
command_handler.execute("INSERT INTO users(username, password, privilege) VALUES(%s, %s, 'student')",query_vals)
db.commit()
print("")
print(username + " has been registered as a student")
elif User_option == "2":
print("")
print("Register New Teacher")
username = input(str("Teacher username: "))
password = input(str("Teacher password : "))
query_vals = (username, password)
command_handler.execute("INSERT INTO users(username, password, privilege) VALUES(%s, %s, 'teacher')",query_vals)
db.commit()
print("")
print(username + " has been registered as a Teacher")
elif User_option == "3":
print("")
print("Delete Existing Student Account")
username = input(str("Student Username : "))
query_vals = (username, "student")
command_handler.execute("DELETE FROM users WHERE username = %s AND privilege = %s", query_vals)
db.commit()
if command_handler.rowcount < 1:
print("User not found")
else:
print("")
print(username + " has been deleted")
elif User_option == "4":
print("")
print("Delete Existing Teacher Account")
username = input(str("Teacher Username : "))
query_vals = (username, "teacher")
command_handler.execute("DELETE FROM users WHERE username = %s AND privilege = %s", query_vals)
db.commit()
if command_handler.rowcount < 1:
print("User not found")
else:
print("")
print(username + " has been deleted")
elif User_option == "5":
break
else:
print("No valid option selected")
def auth_admin():
print("")
print("Admin Login")
print("")
username = input(str("Username: "))
password = input(str("Password: "))
if username == "admin":
if password == "password":
admin_session()
else:
print("")
print("Login details not recognised")
def main():
while 1:
print("Welcome to the college system")
print("")
print("1. Login as student")
print("2. Login as teacher")
print("3. Login as admin")
user_option = input(str("Option : "))
if user_option == "1":
print("Student login")
elif user_option == "2":
print("Teacher login")
elif user_option == "3":
auth_admin()
else:
print("No valid option was selected")
main()