Comp Project
Comp Project
E S RY
AL SC
ND HO
EE OL
GR
SUBMITTED BY:
NAME: JOHN JABEZ N.
CLASS: 12 SCI
ROLL NO:
TO: SIR DAMIAN
ENIOR SECONDA
E S RY
AL SC
ND HO
EE OL
GR
SUBMITTED BY:
NAME: AANSH PANDEY
CLASS: 12 SCI
ROLL NO:
TO: SIR DAMIAN
ENIOR SECONDA
E S RY
AL SC
ND HO
EE OL
GR
SCHOOL ACCOUNTS
MANAGEMENT SYSTEM
SUBMITTED BY:
NAME: REWARD RAI
CLASS: 12 SCI
ROLL NO:
TO: SIR DAMIAN
ACKNOWLEDGMENT
I would like to express my sincere gratitude to everyone who has
contributed to the success of this project.
First and foremost, I would like to thank my teacher/mentor, sir
Damian , for his continuous support, guidance, and valuable feedback
throughout the development of this project.
DATABASE CREATION
The first step involves creating the
school_management database, which
1
serves as the container for all tables
and data. Using CREATE DATABASE
ensures that the system can store TABLE CREATION FOR
information such as user credentials, USERS
student, and teacher details.
2 The users table is created to store
login credentials, such as username,
password, and designation (Admin,
Teacher, Other). This table is essential
TABLE CREATION for managing access control within
FOR STUDENTS the system, ensuring users can log in
The student table stores essential 3 based on their roles.
information about students, including
student_id, name, age, grade, email,
and phone. This table is key to
maintaining student records, TABLE CREATION
facilitating management of their FOR TEACHERS
academic and personal information.
4 The teacher table holds data about
teachers, including teacher_id, name,
subject, salary, and contact details.
This table helps manage teacher
INSERTING SAMPLE records and their associated data
DATA such as salary and subject expertise.
User Registration
In the register_user() function, a new user is
prompted to enter a username and password. The
password is validated using the is_strong_password
function. If the password is strong and confirmed by
the user, the user’s information (username, password,
and designation) is inserted into the users table in
the database.
User Login
In the user_login() function, users are prompted to
enter their username and password. The system checks
the users table in the database to verify the
credentials. If the login is successful, the user’s
designation (Admin/Teacher) is returned to control
the access level.
Admin Operations
Once logged in as an Admin, the user can choose
from various options:
Add a new student: The admin can enter student
details (name, ID, age, grade, etc.) which are
then inserted into the student table in the
database.
View all students: The admin can view a list of
all students stored in the student table.
Add a new teacher: The admin can enter teacher
details (name, ID, subject, salary, etc.) which
are inserted into the teacher table in the
database.
View all teachers: The admin can view all teachers
in the teacher table.
Teacher Operations
Once logged in as a Teacher, the user can perform
limited actions:
View all students: Teachers can view the list of all
students stored in the student table.
View all teachers: Teachers can also view the list of
all teachers stored in the teacher table.
System Exit
After completing tasks, both Admins and Teachers can
exit the system, which closes the connection to the
MySQL database and ends the session.
STEP WISE
EXPLANATION
PYTHON
CODE
import mysql.connector
# Establishing a connection to the MySQL database
conn = mysql.connector.connect(
host='localhost',
user='root', # Replace with your MySQL username
password='himynameisjohn', # Replace with your MySQL password
database='school_management'
)
cursor = conn.cursor()
# Function to check password strength
def is_strong_password(password):
if len(password) < 8:
return False
has_upper = has_lower = has_digit = has_special = False
special_characters = "@$!%*?&"
for char in password:
if char.isupper():
has_upper = True
elif char.islower():
has_lower = True
elif char.isdigit():
has_digit = True
elif char in special_characters:
has_special = True
return has_upper and has_lower and has_digit and has_special
# Function to register a new user
def register_user():
print("\n--- User Registration ---")
username = input("Enter a new username: ")
while True:
password = input("Enter a strong password: ")
if is_strong_password(password):
confirm_password = input("Confirm your password: ")
if password == confirm_password:
designation = input("Enter your designation (Admin/Teacher/Other):
").capitalize()
cursor.execute(
"INSERT INTO users (username, password, designation) VALUES (%s, %s,
%s)",
(username, password, designation)
)
conn.commit()
print("User registered successfully!")
break
else:
print("Passwords do not match. Try again.")
else:
print("Password must be at least 8 characters long and include uppercase,
lowercase, digits, and special characters.")
# Function for user login
def user_login():
print("\n--- User Login ---")
username = input("Enter your username: ")
password = input("Enter your password: ")
cursor.execute("SELECT designation FROM users WHERE username=%s AND
password=%s", (username, password))
result = cursor.fetchone()
if result:
print(f"\nLogin successful! Welcome, {username}.")
designation = result[0]
return designation
else:
print("\nInvalid username or password!")
return None
# Function to add a new student
def add_student():
print("\n--- Add Student ---")
student_id = input("Enter student ID: ")
name = input("Enter student name: ")
father_name = input("Enter father's name: ")
age = int(input("Enter student age: "))
grade = input("Enter student grade: ")
email = input("Enter student email: ")
phone = input("Enter student phone: ")
school_name = input("Enter school name: ")
cursor.execute("""
INSERT INTO student (student_id, name, father_name, age, grade, email, phone,
school_name)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
""", (student_id, name, father_name, age, grade, email, phone, school_name))
conn.commit()
print("Student added successfully!")
# Function to view all students
def view_students():
print("\n--- View Students ---")
cursor.execute("SELECT * FROM student")
records = cursor.fetchall()
for record in records:
print(record)
# Function to add a new teacher
def add_teacher():
print("\n--- Add Teacher ---")
teacher_id = input("Enter teacher ID: ")
name = input("Enter teacher name: ")
subject = input("Enter subject: ")
email = input("Enter teacher email: ")
phone = input("Enter teacher phone: ")
salary = float(input("Enter salary: "))
cursor.execute("""
INSERT INTO teacher (teacher_id, name, subject, email, phone, salary)
VALUES (%s, %s, %s, %s, %s, %s)
""", (teacher_id, name, subject, email, phone, salary))
conn.commit()
print("Teacher added successfully!")
# Function to view all teachers
def view_teachers():
print("\n--- View Teachers ---")
cursor.execute("SELECT * FROM teacher")
records = cursor.fetchall()
for record in records:
print(record)
# Main function to run the School Management System
def main():
print("Welcome to the School Management System")
# User registration if needed
register = input("\nDo you want to register a new user? (yes/no): ").lower()
if register == 'yes':
register_user()
# User login
designation = user_login()
if designation is None:
return
# Display menu options based on designation
while True:
if designation == 'Admin':
print("\nAdmin Menu:\n1. Add Student\n2. View Students\n3. Add
Teacher\n4. View Teachers\n5. Exit")
choice = input("Enter your choice: ")
if choice == '1':
add_student()
elif choice == '2':
view_students()
elif choice == '3':
add_teacher()
elif choice == '4':
view_teachers()
elif choice == '5':
break
elif designation == 'Teacher':
print("\nTeacher Menu:\n1. View Students\n2. View Teachers\n3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
view_students()
elif choice == '2':
view_teachers()
elif choice == '3':
break
if __name__ == "__main__":
main()
# Close the database connection
cursor.close()
conn.close()
OUTPUT...
OF PYTHON CODE
CONCLUSION
The School Management System developed in Python with
a MySQL database integration is a practical demonstration
of how database management can be efficiently applied in
educational institutions. This system enables secure user
registration, login, and role-based access, allowing
administrators to manage student and teacher data
effectively. By leveraging Python for backend logic and
MySQL for persistent data storage, this system highlights
the importance of database-driven applications in
streamlining school management processes. It also
demonstrates fundamental concepts like user
authentication, password security, and data manipulation,
making it a valuable project for both learning and real-
world application.