Student Management

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

OVERVIEW OF PYTHON AND MYSQL

Introduction to Python and MySQL

Python is a versatile and powerful programming language widely used for various
applications, including web development, data analysis, machine learning, and database
management. MySQL, on the other hand, is an open-source relational database
management system (RDBMS) that uses SQL (Structured Query Language) to interact
with data. Combining Python with MySQL allows developers to create robust
applications for managing and processing data efficiently.

Key Features of Python:

1. Ease of Learning and Use: Python's syntax is clean and readable, making it
accessible for beginners and professionals alike.

2. Rich Libraries: Python offers libraries like mysql.connector, SQLAlchemy, and


pymysql to facilitate database operations.

3. Cross-Platform Compatibility: Python can run on various operating systems,


including Windows, macOS, and Linux.

Key Features of MySQL:

1. High Performance: MySQL is optimized for speed and scalability, making it


suitable for both small and large-scale applications.

2. Reliability: It provides robust data security and recovery features, ensuring data
integrity.

3. Flexibility: MySQL supports complex queries, triggers, and stored procedures,


making it adaptable for diverse use cases.

1
ABSTRACT

Synopsis: Student Management System

Title: Development of a Student Management System

**Introduction**:

Managing student records manually is time-consuming and error-prone.


This project aims to develop a **Student Management System** to
streamline tasks such as maintaining student details, tracking
attendance, managing grades, and recording fee payments using
Python and MySQL.

**Objective**:

The system will simplify data management for educational institutions


by providing a user-friendly interface and a secure database. Key
functionalities include adding, updating, viewing, and searching
student records, along with attendance, rank, and fee management.

**Reason for Choosing the Topic**:

The project addresses the inefficiencies of manual record-keeping,


offering an automated solution to improve accuracy, save time, and
enhance accessibility for administrators.

**Expected Outcome**:

The system will provide a reliable, efficient, and scalable platform for
managing student-related data, benefiting educational institutions
through improved operations and reduced administrative burden.

2
REQUIREMENTS
1. Hardware Requirements

-Processor:

Dual-Core or higher (e.g., Intel Core i3 or equivalent)

-RAM:

Minimum 4GB (8GB recommended for smooth performance)

-Storage:

At least 500MB of free space for database and application files

- **Operating System**: Windows 10/11, macOS, or Linux

2. Software Requirements

Python: Version 3.8 or higher

MySQL: Version 8.0 or higher

-Python Libraries:

mysql-connector-python`

tkinter (pre-installed with Python)

3. Installation Instructions

**Step 1: Install Python**

1. Download the latest Python version from


[python.org](https://www.python.org/).

3
2. During installation, check **“Add Python to PATH”** and complete
the setup.

**Step 2: Install MySQL**

1. Download MySQL Community Server from


[mysql.com](https://www.mysql.com/).

2. Complete the setup and configure a new root user with a secure
password.

**Step 3: Set Up the Database**

1. Open MySQL Workbench or Command-Line Client.

2. Create the database and tables using the required commands:

**Step 4: Install Python Libraries**

Run the following command in the terminal:

```bash

pip install mysql-connector-python

```

**Step 5: Run the Application**

1. Save the provided Python code in a file named


`student_management.py`.

2. Open the terminal or command prompt, navigate to the file's


location, and run:

4. How to Use the Application**

1. Launch the Application:

4
After running the script, the Tkinter GUI will appear with a menu bar.

2. Student Management:

- Add, update, delete, view, or search student records using the


options in the "Student Management" menu.

3. Attendance:

- Mark a student's attendance by entering their ID, date, and status


(Present/Absent).

4. RANK:

- Add a grade for a student by specifying their ID, subject, and grade.

5. Fees:

- Record fee payments for students with their ID, amount, and date.

6. Exit:

- Use the "Exit" menu to safely close the application.

5. Notes

- Ensure the MySQL service is running before using the application.

- Input dates in the format `YYYY-MM-DD`.

- Use valid student IDs to avoid errors in attendance, grades, or fees.

- For debugging, check the terminal for error messages.

5
Modules and Libraries Used in the Project

1. **Tkinter**

- Purpose: Provides the graphical user interface (GUI) for the


application, enabling the creation of menus, buttons, entry fields, and
dialogs.

- **Usage**:

- To design forms for adding, updating, and managing student data.

- For creating pop-up windows and menus for user interactions.

2. **MySQL Connector (`mysql-connector-python`)**

- **Purpose**: Connects the Python application to the MySQL


database. It allows executing SQL queries to interact with the database.

- **Usage**:

- To establish a connection to the MySQL database.

- For performing CRUD (Create, Read, Update, Delete) operations on


the database tables.

3. **Datetime**

- **Purpose**: Handles date and time formats to ensure consistency


and compatibility with the database.

- **Usage**:

- To validate and format dates (e.g., converting user-entered dates


to `YYYY-MM-DD` format).

6
4. **Messagebox (from Tkinter)**

- **Purpose**: Displays alerts and informational messages to the user


in pop-up windows.

- **Usage**:

- To notify users of successful operations (e.g., "Student added


successfully").

- To show error messages when invalid data is entered.

5. **Simpledialog (from Tkinter)**

- **Purpose**: Prompts the user to input data through pop-up dialogs.

- **Usage**:

- To take inputs like Student ID for searching or deleting records.

6. **Text (from Tkinter)**

- **Purpose**: Displays multi-line text outputs, such as lists of


students.

- **Usage**:

- To show all student records in a readable format within a new


window.

These modules and libraries work together to provide a user-friendly


interface and seamless interaction between the application and the

Database.

7
Built-in Functions Used in the Project

1. **`str()`**

- **Purpose**: Converts objects into strings.

- **Usage**:

- Used to ensure data is properly formatted when passing it into SQL


queries or when displaying it to the user.

- **Reason**: Ensures data is in string format for SQL operations.

2. **`int()`**

- **Purpose**: Converts input data into integers.

- **Usage**:

- Used to convert user input into integer format, particularly for


student IDs, which are required to be integers for database queries.

- **Reason**: Ensures that IDs are in the correct data type when
used in SQL operations.

3. **`datetime.strptime()`**

- **Purpose**: Converts a string into a `datetime` object.

- **Usage**:

- Used to convert user-inputted dates (in string format) into


`datetime` objects that can then be stored in the database.

- **Reason**: Ensures that dates are in the correct format (`YYYY-


MM-DD`) for database storage.

8
4. **`strptime()`**

- **Purpose**: Parses a string into a `datetime` object based on a


given format.

- **Usage**:

- Converts user input for the date into a `datetime` object for proper
validation and database compatibility.

- **Reason**: Provides validation of date input in a specific format.

5. **`messagebox.showinfo()

`** - **Purpose**: Displays an informational message to the user in a


popup dialog.

- **Usage**:

- Used to notify users when operations are successful (e.g., student


added, attendance marked).

- **Reason**: Enhances user experience by confirming successful


operations.

6. **`messagebox.showerror()`**

- **Purpose**: Displays an error message in a popup dialog.

- **Usage**:

- Used to show error messages if the user inputs invalid data or if


the operation fails (e.g., incorrect date format).

9
- **Reason**: Provides error feedback to the user for corrective
actions.

7. **`cursor.execute()`**

- **Purpose**: Executes a SQL command or query on the MySQL


database.

- **Usage**:

- Used to execute various SQL queries such as insert, update, delete,


and select operations.

- **Reason**: Allows the Python application to interact with the


MySQL database and perform CRUD operations.

8. **`cursor.fetchall()`**

- **Purpose**: Fetches all results from the executed SQL query.

- **Usage**:

- Used after a `SELECT` query to retrieve all rows returned from the
database.

- **Reason**: Provides the ability to fetch multiple rows of data for


further processing or display.

9. **`cursor.fetchone()`**

- **Purpose**: Retrieves the next row of a query result.

10
- **Usage**:

- Used when fetching a single record from the database, such as


when searching for a specific student.

10. **`input()`**

- **Purpose**: Accepts user input from the command line.

- **Usage**:

- Though not explicitly used in the provided code, `input()` can be


used to take user input in some extensions or CLI-based versions of the
project.

- **Reason**: To gather input data from users, which is then


processed by the program.

11.str.format()

- **Purpose**: Formats strings by embedding variables within them.

- **Usage**:

- Used to format output messages dynamically, for example, when


displaying student data.

- **Reason**: Helps in dynamically creating user-friendly messages


or formatted data output.

11
12. **exit()**

- **Purpose**: Terminates the program.

- **Usage**:

- Used to close the application and exit when the user chooses to
quit.

- **Reason**: To properly end the program when the user decides to


exit.

These built-in functions play a critical role in handling user


interactions, executing SQL queries, managing data formats, and
improving the overall functionality of the Student Management
System.

12
SOURCE CODE
import mysql.connector

from tkinter import *

from tkinter import messagebox, simpledialog

from datetime import datetime

# Database connection

try:

db_connection = mysql.connector.connect(

host="localhost",

user="root",

password="manish362121",

database="SchoolDB"

cursor = db_connection.cursor()

except mysql.connector.Error as err:

print(f"Error: {err}")

messagebox.showerror("Database Error", f"Could not connect to


database: {err}")

# Functions for the Student Management System

#CONSISTS OF 9 MENU

def create_student(Name, dob, student_class, contact, email):

query = "INSERT INTO Students (Name, Date_of_Birth, Class,


Contact, Email) VALUES (%s, %s, %s, %s, %s)"

values = (Name, dob, student_class, contact, email)

13
cursor.execute(query, values)

db_connection.commit()

messagebox.showinfo("Success", "Student added successfully!")

def update_student(student_id, Name, dob, student_class, contact,


email):

query = "UPDATE Students SET Name=%s, Date_of_Birth=%s,


Class=%s, Contact=%s, Email=%s WHERE Student_ID=%s"

values = (Name, dob, student_class, contact, email, student_id)

cursor.execute(query, values)

db_connection.commit()

messagebox.showinfo("Success", "Student updated successfully!")

def delete_student(student_id):

query = "DELETE FROM Students WHERE Student_ID=%s"

cursor.execute(query, (student_id,))

db_connection.commit()

messagebox.showinfo("Success", "Student deleted successfully!")

def view_students():

cursor.execute("SELECT * FROM Students")

students = cursor.fetchall()

view_window = Toplevel(root)

view_window.title("View All Students")

text = Text(view_window)

text.pack()

14
for student in students:

text.insert(END, f"ID: {student[0]}, Name: {student[1]}, DOB:


{student[2]}, Class: {student[3]}, Contact: {student[4]}, Email:
{student[5]}\n")

def search_student(student_id):

cursor.execute("SELECT * FROM Students WHERE Student_ID=%s",


(student_id,))

student = cursor.fetchone()

if student:

messagebox.showinfo("Student Found", f"ID: {student[0]}, Name:


{student[1]}, DOB: {student[2]}, Class: {student[3]}, Contact: {student[4]},
Email: {student[5]}")

else:

messagebox.showerror("Not Found", "Student with this ID does not


exist.")

def add_student_window():

def add_student():

name = entry_name.get()

dob = entry_dob.get()

student_class = entry_class.get()

contact = entry_contact.get()

email = entry_email.get()

try:

dob_formatted = datetime.strptime(dob, "%Y-%m-%d").date()

15
create_student(name, dob_formatted.strftime("%Y-%m-%d"),
student_class, contact, email)

except ValueError:

messagebox.showerror("Error", "Date must be in YYYY-MM-DD


format")

add_window = Toplevel(root)

add_window.title("Add Student")

Label(add_window, text="Name").grid(row=0, column=0)

entry_name = Entry(add_window)

entry_name.grid(row=0, column=1)

Label(add_window, text="Date of Birth (YYYY-MM-DD)").grid(row=1,


column=0)

entry_dob = Entry(add_window)

entry_dob.grid(row=1, column=1)

Label(add_window, text="Class").grid(row=2, column=0)

entry_class = Entry(add_window)

entry_class.grid(row=2, column=1)

Label(add_window, text="Contact").grid(row=3, column=0)

entry_contact = Entry(add_window)

entry_contact.grid(row=3, column=1)

Label(add_window, text="Email").grid(row=4, column=0)

entry_email = Entry(add_window)

entry_email.grid(row=4, column=1)

Button(add_window, text="Add Student",


command=add_student).grid(row=5, column=1)

16
def update_student_window():

def update_student_action():

student_id = entry_id.get()

name = entry_name.get()

dob = entry_dob.get()

student_class = entry_class.get()

contact = entry_contact.get()

email = entry_email.get()

try:

dob_formatted = datetime.strptime(dob, "%Y-%m-%d").date()

update_student(student_id, name, dob_formatted.strftime("%Y-


%m-%d"), student_class, contact, email)

except ValueError:

messagebox.showerror("Error", "Date of Birth must be in YYYY-


MM-DD format")

update_window = Toplevel(root)

update_window.title("Update Student")

Label(update_window, text="Student ID").grid(row=0, column=0)

entry_id = Entry(update_window)

entry_id.grid(row=0, column=1)

Label(update_window, text="Name").grid(row=1, column=0)

entry_name = Entry(update_window)

entry_name.grid(row=1, column=1)

Label(update_window, text="Date of Birth (YYYY-MM-


DD)").grid(row=2, column=0)

17
entry_dob = Entry(update_window)

entry_dob.grid(row=2, column=1)

Label(update_window, text="Class").grid(row=3, column=0)

entry_class = Entry(update_window)

entry_class.grid(row=3, column=1)

Label(update_window, text="Contact").grid(row=4, column=0)

entry_contact = Entry(update_window)

entry_contact.grid(row=4, column=1)

Label(update_window, text="Email").grid(row=5, column=0)

entry_email = Entry(update_window)

entry_email.grid(row=5, column=1)

Button(update_window, text="Update Student",


command=update_student_action).grid(row=6, column=1)

# Attendance Functionality

#STUDENT ID MUST ALREADY EXIST

def mark_attendance(student_id, attendance_date, status):

query = "INSERT INTO attendance (Student_ID, Date, Status) VALUES


(%s, %s, %s)"

values = (student_id, attendance_date, status)

cursor.execute(query, values)

db_connection.commit()

messagebox.showinfo("Success", "Attendance marked successfully!")

def mark_attendance_window():

def mark_attendance_action():

18
student_id = entry_student_id.get()

attendance_date = entry_date.get()

status = entry_status.get()

try:

mark_attendance(student_id, attendance_date, status)

except ValueError:

messagebox.showerror("Error", "Invalid data entered.")

attendance_window = Toplevel(root)

attendance_window.title("Mark Attendance")

Label(attendance_window, text="Student ID").grid(row=0, column=0)

entry_student_id = Entry(attendance_window)

entry_student_id.grid(row=0, column=1)

Label(attendance_window, text="Date (YYYY-MM-DD)").grid(row=1,


column=0)

entry_date = Entry(attendance_window)

entry_date.grid(row=1, column=1)

Label(attendance_window, text="Status
(Present/Absent)").grid(row=2, column=0)

entry_status = Entry(attendance_window)

entry_status.grid(row=2, column=1)

Button(attendance_window, text="Mark Attendance",


command=mark_attendance_action).grid(row=3, column=1)

# Grades Functionality

#WHEN GIVING INPUT STUDENT ID MUST EXIST ELSE RAISES ERROR

19
def add_grade(student_id,CLASS, grade):

query = "INSERT INTO Grades (Student_ID,CLASS, Grade) VALUES


(%s, %s, %s)"

values = (student_id,CLASS, grade)

cursor.execute(query, values)

db_connection.commit()

messagebox.showinfo("Success", "rank added successfully!")

def add_grade_window():

def add_grade_action():

student_id = entry_student_id.get()

CLASS = entry_CLASS.get()

grade = entry_grade.get()

try:

add_grade(student_id, CLASS, grade)

except ValueError:

messagebox.showerror("Error", "Invalid data entered.")

grade_window = Toplevel(root)

grade_window.title("Add Grade")

Label(grade_window, text="Student ID").grid(row=0, column=0)

entry_student_id = Entry(grade_window)

entry_student_id.grid(row=0, column=1)

Label(grade_window, text="CLASS").grid(row=1, column=0)

entry_CLASS = Entry(grade_window)

entry_CLASS.grid(row=1, column=1)

20
Label(grade_window, text="RANK").grid(row=2, column=0)

entry_grade = Entry(grade_window)

entry_grade.grid(row=2, column=1)

Button(grade_window, text="Add RANK",


command=add_grade_action).grid(row=3, column=1)

# Fee Management Functionality

def add_fee(student_id, amount, fee_date):

query = "INSERT INTO Fees (Student_ID, Amount, Fee_Date) VALUES


(%s, %s, %s)"

values = (student_id, amount, fee_date)

cursor.execute(query, values)

db_connection.commit()

messagebox.showinfo("Success", "Fee added successfully!")

def add_fee_window():

def add_fee_action():

student_id = entry_student_id.get()

amount = entry_amount.get()

fee_date = entry_fee_date.get()

try:

add_fee(student_id, amount, fee_date)

except ValueError:

messagebox.showerror("Error", "Invalid data entered.")

fee_window = Toplevel(root)

21
fee_window.title("FEES RECEIPT")

Label(fee_window, text="Student ID").grid(row=0, column=0)

entry_student_id = Entry(fee_window)

entry_student_id.grid(row=0, column=1)

Label(fee_window, text="Amount").grid(row=1, column=0)

entry_amount = Entry(fee_window)

entry_amount.grid(row=1, column=1)

Label(fee_window, text="Fee Date (YYYY-MM-DD)").grid(row=2,


column=0)

entry_fee_date = Entry(fee_window)

entry_fee_date.grid(row=2, column=1)

Button(fee_window, text="FEE PAID",


command=add_fee_action).grid(row=3, column=1)

# Exit functionality

def exit_app():

if messagebox.askokcancel("Quit", "Do you want to exit?"):

root.quit()

# Main Tkinter setup

root = Tk()

root.title("School Student Management")

menu = Menu(root)

root.config(menu=menu)

22
# Define menu options

student_menu = Menu(menu, tearoff=0)

menu.add_cascade(label="Student Management", menu=student_menu)

student_menu.add_command(label="Add Student",
command=add_student_window)

student_menu.add_command(label="Update Student",
command=update_student_window)

student_menu.add_command(label="Delete Student",
command=lambda: delete_student(int(simpledialog.askstring("Delete
Student", "Enter Student ID to delete:"))))

student_menu.add_command(label="View Students",
command=view_students)

student_menu.add_command(label="Search Student",
command=lambda: search_student(int(simpledialog.askstring("Search
Student", "Enter Student ID to search:"))))

attendance_menu = Menu(menu, tearoff=0)

menu.add_cascade(label="Attendance", menu=attendance_menu)

attendance_menu.add_command(label="Mark Attendance",
command=mark_attendance_window)

grades_menu = Menu(menu, tearoff=0)

menu.add_cascade(label="rank", menu=grades_menu)

grades_menu.add_command(label="Add rank",
command=add_grade_window)

fee_menu = Menu(menu, tearoff=0)

menu.add_cascade(label="Fee RECEIPT", menu=fee_menu)

23
fee_menu.add_command(label="Add Fee PAID",
command=add_fee_window)

# Add Exit Menu

menu.add_command(label="Exit", command=exit_app)

root.mainloop()

24
OUTPUT

1.ADD-for adding student details:

A pop up window confirms the addition of student data.

25
DELETE: deletes student record from records.

After deleting a window pop up confirms the deletion.

SEARCH: searches the record for the details

a pop up gives us the details of student

26
VIEW: gives us the records of all students.

UPDATE: for updating student details using student_id.

A pop up will confirm the changes.

27
IN THIS VIEW ALL STUDENTS TAB WE CAN CONFIRM THAT THE
DETAILS OF ID:7 HAS ITS DATE OF BIRTH AND PHNO NO UPDATED

ATTENDANCE: marks the attendance of students and stores


the data in databse.

Attendance is directly reflected in the table Attendance in


database schoolDB

28
RANK: assigns the rank to student in their respective classes

A pop up window confirms the execution.

The ranks are store in table Grades.

29
FEES RECEIPT: it stores the details of student who have
paid the fees.

Fees of students paid is reflected in databse.

30
CONCLUSION
Comprehensive Solution: The Student Management System offers a
complete solution for handling essential administrative tasks in
educational institutions.

User-Friendly Interface: Utilizing Tkinter for the GUI provides an


intuitive and accessible interface, making it easy for users to navigate
and perform operations.

Efficient Database Management: MySQL serves as a reliable database


solution, facilitating efficient management of student records,
including adding, updating, deleting, viewing, and searching
information.

Attendance, Grades, and Fee Management: The system extends


functionality to manage attendance, grades, and fee payments, allowing
for a unified tracking of academic and financial records.

Real-Time Feedback: With built-in error handling and data validation,


the system provides instant feedback to users, reducing the likelihood
of common input errors and ensuring data accuracy.

Data Integrity and Security: Leveraging MySQL as the backend


database ensures secure data storage, integrity, and reliability in
managing sensitive student information.

Simplified Administrative Workflows: By automating tasks, the system


streamlines administrative workflows, freeing up time for staff and
improving overall efficiency.

31
FUTURE OUTLOOK
Future Outlook: Possible Updates for the Student Management System

To further enhance the functionality, usability, and scalability of the


**Student Management System**, here are several potential updates
that can be incorporated:

1. **User Authentication & Authorization**:

- Implement user login with different roles (e.g., Admin, Teacher,


Student) to control access to certain features and ensure that sensitive
data is only accessible by authorized personnel.

2. **Automated Reports Generation**:

- Enable the system to generate various reports such as student


attendance, grade summaries, fee payment history, and performance
analysis.

- Provide options to export reports in different formats like PDF,


Excel, or CSV for easy sharing and printing.

3. **Email Notifications**:

- Send automatic notifications to students and parents about


attendance, upcoming exams, fee deadlines, and other important
events.

- Implement email reminders for fee payments or attendance issues.

4. **Integration with Online Platforms**:

- Integrate the system with online learning platforms or school portals


to sync student records, grades, and attendance with external systems.

32
- Link with other school management software (e.g., learning
management systems or academic portals).

5. **Mobile App Version**:

- Develop a mobile version of the system, allowing teachers, students,


and parents to access key features (like attendance, grades, and fee
payments) on-the-go.

6. **Student Performance Analytics**:

- Add functionality for analyzing student performance over time,


including visualizing grades, attendance patterns, and participation.

- Implement features for tracking student progress, identifying at-


risk students, and generating insights for educators.

7. **Advanced Fee Management**:

- Implement a more advanced fee management system with options


for fee installments, discounts, and late fee penalties.

- Provide an online payment gateway for fee payments.

8. **Calendar Integration**:

- Add a calendar feature for scheduling school events, exams, and


class timetables, which can be linked to students' profiles for
personalized reminders.

9. **Data Backup & Recovery**:

- Implement an automatic backup system to ensure that all student


data is regularly saved and can be restored in case of system failures.

33
REFRENCES

1.https://www.geeksforgeeks.org/python-gui-tkinter/

2.https://www.javatpoint.com/python-tkinter

3.https://stackoverflow.com/questions/40843698/how-to-auto-
activate-a- tkinter-simpledialog-pop-up-window

4.https://www.w3resource.com/python-
exercises/tkinter/python-tkinter-dialogs-and-file-handling-
exercise-1.php

5.https://www.w3schools.com/python/python_mysql_select.asp

34

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy