Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23247

Why doesnt the programm insert the data that i type in? [closed]

$
0
0
import sqlite3import refrom tkinter import messageboxonlyNumber = r'^\d+$'onlyLetters = r'^[a-zA-Z\s]+$'onlyAge = r'^\d+$'def insertStudent(student_id, full_name, age):    if re.match(onlyNumber, student_id) and re.match(onlyLetters, full_name) and re.match(onlyAge, age):        try:            with sqlite3.connect('school.sqlite') as conn:                cursor = conn.cursor()                cursor.execute("INSERT INTO student (StudentID, FullName, Age) VALUES (?, ?, ?)",                               (student_id, full_name, age))                conn.commit()                messagebox.showinfo("Success", "Student successfully added to the database.")        except sqlite3.Error as e:            print(f"An error occurred: {e}")            messagebox.showerror("Error", "An error occurred while adding the student to the database.")    else:        print("Invalid input. Only numbers allowed for ID and Age, and only letters for Full Name.")        messagebox.showerror("Invalid Input", "Please enter valid data.")from tkinter import *import customtkinter as ctkfrom school.backendSchool import insertStudentwindowMenu = ctk.CTk()studentEntry = ctk.CTk()windowMenu.title("Menu")windowMenu.geometry("1280x720")def buttonToMenu():    studentEntry.withdraw()    windowMenu.deiconify()def buttonToStudent():    windowMenu.withdraw()    studentEntry.title("Student Entry")    studentEntry.geometry("1280x720")    studentEntry.deiconify()entryStudentID = ctk.CTkEntry(studentEntry)entryStudentID.pack(anchor=CENTER)entryStudentName = ctk.CTkEntry(studentEntry)entryStudentName.pack(anchor=CENTER)entryStudentAge = ctk.CTkEntry(studentEntry)entryStudentAge.pack(anchor=CENTER)buttonStudentTable = ctk.CTkButton(studentEntry, text="Create Student",                                   command=lambda: insertStudent(entryStudentID.get().strip(),                                                                 entryStudentName.get().strip(),                                                                 entryStudentAge.get().strip()))buttonStudentTable.pack(anchor=CENTER)buttonStudent = ctk.CTkButton(windowMenu, text="Student", command=buttonToStudent)buttonStudent.pack(anchor=CENTER)buttonMenu = ctk.CTkButton(studentEntry, text="Menu", command=buttonToMenu)buttonMenu.pack(anchor=CENTER)buttonToQuit = ctk.CTkButton(windowMenu, text="Quit", command=windowMenu.destroy)buttonToQuit.pack(anchor=CENTER)buttonToQuitStudent = ctk.CTkButton(studentEntry, text="Quit", command=studentEntry.destroy)buttonToQuitStudent.pack(anchor=CENTER)windowMenu.mainloop()

I have the problem that after typing some information into the entries and clicking on the insert data button i get the exception all the time, i was not able to find the cause of this exception.

I tried everything and even using AI!Please help.I added the picture for potential project structure questions


Viewing all articles
Browse latest Browse all 23247

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>