Here’s a basic outline for creating a “Student Management System” using Python. This project will involve managing student data (such as name, roll number, class, marks, and attendance) with features to add, update, delete, and view student records.
1. Project Setup
Modules Required:
tkinter
(for the GUI)sqlite3
(for database management)
To install necessary modules, you can use the following:
bashCopy codepip install tkinter
2. Project Features
- Add Student: Add new students with details such as Name, Roll Number, Class, and Marks.
- Update Student: Edit existing student records to modify their details.
- Delete Student: Remove a student record based on Roll Number or Name.
- View All Students: View all student records stored in the database.
- Search Student: Search for a specific student by Roll Number or Name.
- Attendance Tracking: Add or update student attendance.
3. Database Design
We’ll use SQLite to manage the student database, containing the following fields:
- id (INTEGER PRIMARY KEY AUTOINCREMENT)
- name (TEXT)
- roll_number (TEXT)
- class (TEXT)
- marks (REAL)
- attendance (INTEGER)
4. Code Structure
A. Database Connection
import sqlite3
def connect_db():
conn = sqlite3.connect('student_management.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS student
(id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
roll_number TEXT,
class TEXT,
marks REAL,
attendance INTEGER)''')
conn.commit()
conn.close()
connect_db()
B. Add Student Function
def add_student(name, roll_number, class_name, marks, attendance):
conn = sqlite3.connect('student_management.db')
c = conn.cursor()
c.execute("INSERT INTO student (name, roll_number, class, marks, attendance) VALUES (?, ?, ?, ?, ?)",
(name, roll_number, class_name, marks, attendance))
conn.commit()
conn.close()
C. View Students Function
def view_students():
conn = sqlite3.connect('student_management.db')
c = conn.cursor()
c.execute("SELECT * FROM student")
rows = c.fetchall()
conn.close()
return rows
D. Update Student Function
def update_student(id, name, roll_number, class_name, marks, attendance):
conn = sqlite3.connect('student_management.db')
c = conn.cursor()
c.execute("UPDATE student SET name=?, roll_number=?, class=?, marks=?, attendance=? WHERE id=?",
(name, roll_number, class_name, marks, attendance, id))
conn.commit()
conn.close()
E. Delete Student Function
def delete_student(id):
conn = sqlite3.connect('student_management.db')
c = conn.cursor()
c.execute("DELETE FROM student WHERE id=?", (id,))
conn.commit()
conn.close()
5. GUI Design using Tkinter
Here’s a simple implementation for the GUI part:
from tkinter import *
from tkinter import messagebox
import sqlite3
# Main Window
root = Tk()
root.title("Student Management System")
root.geometry("600x400")
# Function to Add Student from GUI
def add_student_gui():
name = name_entry.get()
roll_number = roll_number_entry.get()
class_name = class_entry.get()
marks = marks_entry.get()
attendance = attendance_entry.get()
if name and roll_number:
add_student(name, roll_number, class_name, float(marks), int(attendance))
messagebox.showinfo("Success", "Student added successfully!")
else:
messagebox.showerror("Error", "Please fill in all the fields!")
# GUI Elements
Label(root, text="Name").grid(row=0, column=0, padx=20, pady=10)
name_entry = Entry(root)
name_entry.grid(row=0, column=1)
Label(root, text="Roll Number").grid(row=1, column=0, padx=20, pady=10)
roll_number_entry = Entry(root)
roll_number_entry.grid(row=1, column=1)
Label(root, text="Class").grid(row=2, column=0, padx=20, pady=10)
class_entry = Entry(root)
class_entry.grid(row=2, column=1)
Label(root, text="Marks").grid(row=3, column=0, padx=20, pady=10)
marks_entry = Entry(root)
marks_entry.grid(row=3, column=1)
Label(root, text="Attendance").grid(row=4, column=0, padx=20, pady=10)
attendance_entry = Entry(root)
attendance_entry.grid(row=4, column=1)
Button(root, text="Add Student", command=add_student_gui).grid(row=5, column=0, columnspan=2, pady=20)
root.mainloop()
6. Final Touches
- Add validation to check if all fields are filled.
- Include a button to view all students in a separate window.
- Implement search functionality to look up a student by name or roll number.
7. Conclusion
This is a simple Student Management System project using Python, Tkinter for the GUI, and SQLite for database management. You can expand the project by adding features like grade calculation, attendance percentage tracking, and report generation.
Would you like any specific enhancements or additional features in this project?