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
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
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...
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS OR SWITCH STATEMENTS IN THE JAVASCRIPT. Even though there is stylesheet in the HTML file do no create a new one. Project Standards: Students will use click events to capture user input. Students will use variables to store information needed by their application and keep track of their program’s state. Students will use conditionals to control project flow. Project Task You will be building...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
Scenario: You recently started working as the mobile app developer for a University and have been...
Scenario: You recently started working as the mobile app developer for a University and have been assigned to build a mobile app that calculates the students' grade. Your app should contain following screens: Screen 1 Labels for subject1, subject2, and subject3 Textboxes for subject1, subject2, and subject3 Labels for MaxGrade, MinGrade, and Avg.Grade Submit button Once user clicks submit button, you need to display letter grade in a label Screen 2 Screen that allows students to register for the course...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...