Question

PYTHON Use Tkinter to display a My sql table and create a delete button that allows...

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" )

Homework Answers

Answer #1
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)
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
Coding in Python Add radio button options for filing status to the tax calculator program of...
Coding in Python Add radio button options for filing status to the tax calculator program of Project 1. The user selects one of these options to determine the tax rate. The Single option’s rate is 20%. The Married option is 15%. The Divorced option is 10%. The default option is Single. Be sure to use the field names provided in the comments in your starter code. ================== Project 1 code: # Initialize the constants TAX_RATE = 0.20 STANDARD_DEDUCTION = 10000.0...
Use the Donor database attached to the assignment answer the following: Question 1: Create a block...
Use the Donor database attached to the assignment answer the following: Question 1: Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. 2 marks...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT