This repository contains is a comprehensive student management system built with Python, Tkinter, and PostgreSQL for managing student information and grades, as part of Module 12: Building Database Apps with PostgreSQL & Python.
- Add new students with name, email, class, and phone
- Update existing student information
- Delete students (with cascade deletion of grades)
- View all students in a sortable table
- Input validation for required fields
- Add grades for students by subject
- Update existing grades
- Delete grades
- Support for custom maximum marks
- Automatic percentage calculation
- View all grades with student information
- Search students by name (case-insensitive)
- Filter students by class
- Filter grades by subject
- Reset all filters to show complete data
- Combined view of students and their grades
- PostgreSQL database with proper relationships
- Foreign key constraints with cascade deletion
- Data validation and error handling
- Sample data for testing
- Python 3.7 or higher
- PostgreSQL database server
- Required Python packages (see requirements.txt)
-
Install PostgreSQL
- Download and install PostgreSQL from https://www.postgresql.org/
- Create a database named "testDb"
- Set up a user "postgres" with password "1234" (or modify db_config.py)
-
Install Python Dependencies
pip install psycopg2-binary or pip install psycopg2
-
Database Setup
- Ensure your PostgreSQL server is running
- Run the test script:
python test.py
-
Run the Application
python main.py
student_management_system/
├── main.py # Main application file
├── db_config.py # Database configuration
├── Assignment 7.pdf # Assignment Text
└── README.md # This file
id
: Primary key (Serial)name
: Student name (VARCHAR 100, NOT NULL)email
: Student email (VARCHAR 100, UNIQUE, NOT NULL)class_name
: Student class (VARCHAR 50, NOT NULL)phone
: Phone number (VARCHAR 20)created_at
: Timestamp (DEFAULT CURRENT_TIMESTAMP)
id
: Primary key (Serial)student_id
: Foreign key to students tablesubject
: Subject name (VARCHAR 100, NOT NULL)grade
: Grade obtained (DECIMAL 5,2, NOT NULL)max_marks
: Maximum marks (DECIMAL 5,2, DEFAULT 100)exam_date
: Date of exam (DATE)created_at
: Timestamp (DEFAULT CURRENT_TIMESTAMP)
- Go to the "Students" tab
- Fill in the required fields (Name, Email, Class)
- Phone number is optional
- Click "Add Student"
- Go to the "Grades" tab
- Select a student from the dropdown
- Enter subject, grade, and maximum marks
- Click "Add Grade"
- Go to the "Search & Filter" tab
- Use any of the search options:
- Search by student name
- Filter by class
- Filter by subject
- Click "Reset All" to clear filters
- Select a record in any table
- The form fields will auto-populate
- Modify the desired fields
- Click "Update Student" or "Update Grade"
- Select a record in any table
- Click "Delete Student" or "Delete Grade"
- Confirm the deletion in the popup dialog
To modify database connection settings, edit db_config.py
:
def connect():
return psycopg2.connect(
dbname="your_database_name",
user="your_username",
password="your_password",
host="your_host",
port="your_port"
)
The application includes comprehensive error handling for:
- Database connection issues
- Invalid input data
- Duplicate email addresses
- Missing required fields
- Database constraint violations
-
Database Connection Error
- Ensure PostgreSQL is running
- Check database credentials in db_config.py
- Verify database "testDb" exists
-
Module Not Found Error
- Install required packages
- Ensure Python 3.7+ is installed
-
Permission Denied
- Check PostgreSQL user permissions
- Ensure user has CREATE, INSERT, UPDATE, DELETE privileges
-
Tkinter Not Found
- On Linux:
sudo apt-get install python3-tk
- On macOS: Usually included with Python
- On Windows: Included with Python installer
- On Linux:
This assignment is based on:
- Module 10: Introduction to GUI using Tkinter
- Module 11: Building GUI Projects
- Module 12: Building Database Apps with PostgreSQL & Python
- ✅ Performs
CURD
operations with search functions. - ✅ UI buttons work as expected with responsive layout.