Skip to content

Commit 3f46131

Browse files
committed
IDK
0 parents  commit 3f46131

936 files changed

Lines changed: 27182 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
env/
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
24+
# Virtual Environment
25+
.venv/
26+
venv/
27+
ENV/
28+
29+
# Environment Variables
30+
.env
31+
32+
# IDEs
33+
.vscode/
34+
.idea/
35+
*.swp
36+
*.swo
37+
.vs/
38+
*.spec
39+
40+
# OS
41+
Thumbs.db
42+
Desktop.ini
43+
44+
# Project specific
45+
GUI-App-v2/
46+
student_report_*.xlsx
47+
48+
# Java
49+
target/
50+
*.class
51+
*.jar
52+
.project
53+
.classpath
54+
.settings/
55+
*.iml
56+
student_report_*.csv

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Student GUI with SQL
2+
3+
MIT License
4+
5+
Copyright (c) 2026 toxicbishop
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Student Management System (Python Edition)
2+
3+
A comprehensive Student Management System built with **Python**, **Tkinter**, and **MySQL**. This repository contains two versions of the application, representing the evolution from a basic CRUD tool to a more advanced system with data visualization.
4+
5+
## 📁 Versions
6+
7+
### [Version 1](./Student-GUI-with-SQL-version-1/)
8+
9+
- **Focus**: Core CRUD operations.
10+
- **UI**: Standard Tkinter interface.
11+
- **Features**: Add, View, and Delete student records with persistent MySQL storage.
12+
13+
### [Version 2](./Student-GUI-with-SQL-version-2/)
14+
15+
- **Focus**: Advanced Features & Analytics.
16+
- **UI**: Enhanced Tkinter interface with improved layout.
17+
- **Features**:
18+
- Full CRUD support.
19+
- Data visualization (Bar Charts) using `matplotlib`.
20+
- CSV Export functionality.
21+
- Robust search and filtering.
22+
23+
## 🚀 Features
24+
25+
- **Tkinter GUI**: Intuitive desktop interface for easy record management.
26+
- **MySQL Integration**: Persistent storage for all student data and marks.
27+
- **Analytics**: Visualize student performance across different subjects (v2).
28+
- **Export**: Save records to CSV for external reporting (v2).
29+
30+
## 🛠 Tech Stack
31+
32+
- **Language**: Python 3.x
33+
- **GUI Framework**: Tkinter
34+
- **Database**: MySQL
35+
- **Data Visualization**: Matplotlib
36+
- **Utilities**: Connector/Python, OpenCSV (equivalent logic)
37+
38+
## ⚙️ Prerequisites
39+
40+
- Python 3.8+
41+
- MySQL Server
42+
- Required Libraries:
43+
44+
```bash
45+
pip install mysql-connector-python matplotlib
46+
```
47+
48+
## 🔧 Setup & Usage
49+
50+
1. **Configure Database**
51+
- Create a MySQL database named `school_db`.
52+
- Ensure your credentials are set correctly in the source files (or `.env` if configured).
53+
54+
2. **Run Version 1**
55+
56+
```bash
57+
cd Student-GUI-with-SQL-version-1
58+
python main.py
59+
```
60+
61+
3. **Run Version 2**
62+
63+
```bash
64+
cd Student-GUI-with-SQL-version-2
65+
python main.py
66+
```
67+
68+
## 📄 License
69+
70+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.venv/
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
.db/
7+
.env
8+
build/
9+
dist/
10+
*.spec
11+
.git/
12+
.gitignore
13+
.vscode/
14+
.vs/
15+
*.xlsx
16+
*.log
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Database Configuration
2+
DB_HOST=host
3+
DB_USER=user
4+
DB_PASS=password
5+
DB_NAME=name
6+
DB_PORT=3306
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.10-slim
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE=1
6+
ENV PYTHONUNBUFFERED=1
7+
8+
# Install system dependencies for GUI (Tkinter) and X11 support
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
python3-tk \
11+
tk-dev \
12+
libx11-6 \
13+
libsm6 \
14+
libice6 \
15+
libxext6 \
16+
libxrender1 \
17+
libxinerama1 \
18+
libxi6 \
19+
libxcursor1 \
20+
libxcomposite1 \
21+
libxdamage1 \
22+
libxrandr2 \
23+
libfontconfig1 \
24+
libgl1 \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Set the working directory in the container
28+
WORKDIR /app
29+
30+
# Copy the requirements file into the container
31+
COPY requirements.txt .
32+
33+
# Install Python dependencies
34+
RUN pip install --no-cache-dir -r requirements.txt
35+
36+
# Copy the rest of the application code
37+
COPY . .
38+
39+
# Default command to run the application
40+
# Note: GUI applications require an X Server running on the host (e.g., VcXsrv or Xming on Windows)
41+
# Run with: docker run -it --rm -e DISPLAY=host.docker.internal:0.0 your-image-name
42+
CMD ["python", "gui_app_v2.py"]
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import os # Used to access OS functionality, specifically to read environment variables (like DB credentials).
2+
from dotenv import load_dotenv # Loads environment variables from a .env file into os.environ for secure configuration.
3+
import tkinter as tk # The standard Python interface to the Tcl/Tk GUI toolkit, used to build the main application window and widgets.
4+
from tkinter import messagebox # A submodule of tkinter used specifically to display pop-up dialogs (e.g., error messages, warnings, info alerts).
5+
import pymysql # A pure-Python MySQL client library used to connect to and communicate with a MySQL database.
6+
import uuid # Used to generate Universally Unique Identifiers (UUIDs), often used for creating unique primary keys for database records.
7+
from input_validator import validate_student_data, sanitize_string # Input validation to prevent SQL injection
8+
9+
load_dotenv() # 1. Load the secrets from the .env file
10+
11+
# 2. Get the values safely
12+
# If the file is missing, these will be None
13+
DB_CONFIG = {
14+
'host': os.getenv('DB_HOST'),
15+
'port': int(os.getenv('DB_PORT', 3306)), # Default to 3306 if missing
16+
'user': os.getenv('DB_USER'),
17+
'password': os.getenv('DB_PASS'),
18+
'database': os.getenv('DB_NAME'),
19+
'cursorclass': pymysql.cursors.DictCursor
20+
}
21+
class StudentApp:
22+
def __init__(self, root):
23+
self.root = root
24+
self.root.title("🎓 Student Management System")
25+
self.root.geometry("600x500")
26+
27+
# Title Label
28+
title_label = tk.Label(root, text="Student Marks Entry", font=("Arial", 18, "bold"))
29+
title_label.pack(pady=10)
30+
31+
# --- FORM FRAME ---
32+
form_frame = tk.Frame(root)
33+
form_frame.pack(pady=10)
34+
35+
# Name
36+
tk.Label(form_frame, text="Student Name:").grid(row=0, column=0, padx=5, pady=5)
37+
self.name_entry = tk.Entry(form_frame)
38+
self.name_entry.grid(row=0, column=1, padx=5, pady=5)
39+
40+
# Roll No
41+
tk.Label(form_frame, text="Roll Number:").grid(row=1, column=0, padx=5, pady=5)
42+
self.roll_entry = tk.Entry(form_frame)
43+
self.roll_entry.grid(row=1, column=1, padx=5, pady=5)
44+
45+
# --- MARKS FRAME ---
46+
marks_frame = tk.LabelFrame(root, text="Subject Marks")
47+
marks_frame.pack(fill="both", expand=True, padx=20, pady=10)
48+
49+
self.subjects = ["Science", "Social", "Maths", "English", "Hindi", "Kannada"]
50+
self.entries = {}
51+
52+
# Create input boxes for all subjects dynamically
53+
for i, sub in enumerate(self.subjects):
54+
tk.Label(marks_frame, text=sub).grid(row=i, column=0, padx=10, pady=5)
55+
entry = tk.Entry(marks_frame)
56+
entry.grid(row=i, column=1, padx=10, pady=5)
57+
self.entries[sub] = entry
58+
59+
# Submit Button
60+
submit_btn = tk.Button(root, text="💾 Save to Database", command=self.save_data,
61+
bg="green", fg="white", font=("Arial", 12))
62+
submit_btn.pack(pady=20)
63+
64+
# Status Bar
65+
self.status_var = tk.StringVar()
66+
self.status_var.set("Ready to connect...")
67+
tk.Label(root, textvariable=self.status_var, bd=1, relief=tk.SUNKEN, anchor=tk.W).pack(side=tk.BOTTOM, fill=tk.X)
68+
69+
def save_data(self):
70+
name = self.name_entry.get()
71+
roll_txt = self.roll_entry.get()
72+
73+
# Collect marks as strings for validation
74+
marks_input = {}
75+
for sub_name in self.subjects:
76+
marks_input[sub_name] = self.entries[sub_name].get()
77+
78+
# Validate all input data using the input validator
79+
is_valid, error_msg, validated_data = validate_student_data(name, roll_txt, marks_input)
80+
81+
if not is_valid:
82+
messagebox.showerror("Validation Error", error_msg)
83+
return
84+
85+
# Use validated and sanitized data
86+
name = validated_data['name']
87+
roll_no = validated_data['roll_no']
88+
marks = validated_data['marks']
89+
90+
# Connect to Database
91+
conn = None
92+
try:
93+
self.status_var.set("Connecting to server...")
94+
self.root.update_idletasks() # Force UI update
95+
96+
conn = pymysql.connect(**DB_CONFIG)
97+
cursor = conn.cursor()
98+
99+
# 1. Insert Student
100+
try:
101+
cursor.execute("INSERT INTO STUDENTS (ROLL_NO, NAME) VALUES (%s, %s)", (roll_no, name))
102+
except pymysql.err.IntegrityError as e:
103+
# If error is 1062 (Duplicate), we just ignore it and move to marks
104+
if e.args[0] != 1062:
105+
raise e
106+
107+
# 2. Insert Marks
108+
# Map names to IDs
109+
sub_ids = {"Science": 101, "Social": 102, "Maths": 103, "English": 104, "Hindi": 105, "Kannada": 106}
110+
111+
for sub_name, marks_value in marks.items():
112+
sub_id = sub_ids[sub_name]
113+
unique_id = str(uuid.uuid4())
114+
115+
cursor.execute("""
116+
INSERT INTO MARKS (ID, ROLL_NO, SUBJ_ID, MARKS)
117+
VALUES (%s, %s, %s, %s)
118+
""", (unique_id, roll_no, sub_id, marks_value))
119+
120+
conn.commit()
121+
messagebox.showinfo("Success", f"Data saved for {name}!")
122+
self.status_var.set("Data Saved Successfully.")
123+
124+
# Clear form
125+
self.name_entry.delete(0, tk.END)
126+
self.roll_entry.delete(0, tk.END)
127+
for e in self.entries.values():
128+
e.delete(0, tk.END)
129+
130+
except Exception as e:
131+
messagebox.showerror("Database Error", str(e))
132+
self.status_var.set("Error occurred.")
133+
finally:
134+
if conn: conn.close()
135+
136+
if __name__ == "__main__":
137+
root = tk.Tk()
138+
app = StudentApp(root)
139+
140+
root.mainloop()

0 commit comments

Comments
 (0)