PYTHON
Use Tkinter to display a My sql table and create a delete button that allows the user to delete entries with the vin field only ONLY error is displayed is the vin is not matched other wise Update tkinter if delete is successfuland dispaly updated table. Use the following database db = mc.connect( host="34.121.209.242", user="root", passwd="1234qwer", database="cars" )
import tkinter as tk
from tkinter import *
from sqlalchemy import create_engine
my_conn = create_engine("mysql+mysqldb://root:[email protected]/cars")
####### end of connection ####
r_set=my_conn.execute("SELECT * FROM cars;")
my_w = tk.Tk()
my_w.geometry("800x600")
val = tk.StringVar()
i=0
for data in r_set:
for j in range(len(data)):
#e = Entry(my_w, width=10, fg='blue')
e = Entry(my_w)
e.grid(row=i, column=j)
e.insert(END, data[j])
i=i+1
e1 = Entry(my_w, textvariable = val)
e1.grid(row=i, column=0)
global val1
val1 = val.get()
print(val1)
#canvas1.create_window(200, 140, window=entry1)
B = tk.Button(my_w, text ="Delete", command = deleteCars)
B.grid(row=i+1,column=0)
my_w.mainloop()
def deleteCars():
r_set=my_conn.execute("DELETE FROM cars WHERE vin = " + val1)
Get Answers For Free
Most questions answered within 1 hours.