| Server IP : 172.64.80.1 / Your IP : 172.70.131.126 Web Server : Apache System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64 User : federalpolyede.edu.ng_idh35skikv ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/federalpolyede.edu.ng/phd_code/ |
Upload File : |
from tkinter import *
import mysql.connector
window = Tk()
window.title("GUI Title")
# Add your GUI components here
window.mainloop()
# Create a label
label = Label(window, text="Enter your name:")
label.pack()
# Create an entry field
entry = Entry(window)
entry.pack()
# Create a button
button = Button(window, text="Submit")
button.pack()
# Connect to MySQL database
db = mysql.connector.connect(
host="localhost",
user="your_username",
password="your_password",
database="your_database"
)
# Create a cursor object to execute SQL queries
cursor = db.cursor()
# Example: Insert data into a table
name = entry.get() # Get the value entered in the entry field
query = "INSERT INTO your_table (name) VALUES (%s)"
values = (name,)
cursor.execute(query, values)
db.commit()
cursor.close()
db.close()