0% found this document useful (0 votes)
2 views

app.py

The document is a Python script that connects to a MySQL database to manage student performance data. It includes a GUI built with Tkinter for adding student information such as name, date of birth, class, and section. The script validates input fields and provides success or error messages based on the user's actions.

Uploaded by

yashyashwant50
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

app.py

The document is a Python script that connects to a MySQL database to manage student performance data. It includes a GUI built with Tkinter for adding student information such as name, date of birth, class, and section. The script validates input fields and provides success or error messages based on the user's actions.

Uploaded by

yashyashwant50
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import mysql.

connector
import tkinter as tk
from tkinter import messagebox

# Connect to MySQL Database


db = mysql.connector.connect(
host="localhost",
user="root",
password="", # Add your MySQL password if set
database="StudentPerformanceDB"
)
cursor = db.cursor()

# Function to add student data


def add_student():
name = name_entry.get()
dob = dob_entry.get()
student_class = class_entry.get()
section = section_entry.get()

if name and dob and student_class and section:


cursor.execute("INSERT INTO Students (name, dob, class, section) VALUES
(%s, %s, %s, %s)",
(name, dob, student_class, section))
db.commit()
messagebox.showinfo("Success", "Student Added Successfully!")
else:
messagebox.showerror("Error", "Please fill all fields")

# GUI Setup
root = tk.Tk()
root.title("Student Performance Management")
root.geometry("400x300")

tk.Label(root, text="Student Name:").pack()


name_entry = tk.Entry(root)
name_entry.pack()

tk.Label(root, text="Date of Birth (YYYY-MM-DD):").pack()


dob_entry = tk.Entry(root)
dob_entry.pack()

tk.Label(root, text="Class:").pack()
class_entry = tk.Entry(root)
class_entry.pack()

tk.Label(root, text="Section:").pack()
section_entry = tk.Entry(root)
section_entry.pack()

tk.Button(root, text="Add Student", command=add_student).pack()

root.mainloop()

You might also like