College Management
College Management
if choice == "1":
# View courses logic
cursor.execute("SELECT * FROM courses")
courses = cursor.fetchall()
for course in courses:
print(course)
elif choice == "2":
# Enroll in a course logic
course_id = input("Enter the course ID: ")
student_id = input("Enter your student ID: ")
# Your code to enroll the student in the course
elif choice == "3":
# View grades logic
student_id = input("Enter your student ID: ")
# Your code to fetch and display the student's grades
elif choice == "4":
break
else:
print("Invalid choice. Please try again.")
if choice == "1":
# View courses logic
cursor.execute("SELECT * FROM courses")
courses = cursor.fetchall()
for course in courses:
print(course)
elif choice == "2":
# Add a course logic
course_id = input("Enter the course ID: ")
course_name = input("Enter the course name: ")
# Your code to add the course to the database
elif choice == "3":
# Update grades logic
student_id = input("Enter the student ID: ")
course_id = input("Enter the course ID: ")
new_grade = input("Enter the new grade: ")
# Your code to update the student's grade in the database
elif choice == "4":
break
else:
print("Invalid choice. Please try again.")
if choice == "1":
# Add student logic
student_id = input("Enter the student ID: ")
student_name = input("Enter the student name: ")
# Your code to add the student to the database
elif choice == "2":
# Add teacher logic
teacher_id = input("Enter the teacher ID: ")
teacher_name = input("Enter the teacher name: ")
# Your code to add the teacher to the database
elif choice =="3":
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(username + " has been deleted")
elif choice=="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(username + " has been deleted")
elif choice == "5":
break
else:
print("Invalid choice. Please try again.")
# Main function
def main():
while True:
print("1. Student")
print("2. Teacher")
print("3. Admin")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == "1":
student_operations()
elif choice == "2":
teacher_operations()
elif choice == "3":
admin_operations()
elif choice == "4":
break
else:
print("Invalid choice. Please try again.")