Delete A Record From Our Database - Python Tkinter GUI Tutorial #21

Delete A Record From Our Database - Python Tkinter GUI Tutorial #21

Codemy.com

5 лет назад

61,657 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@DARKxDANI47
@DARKxDANI47 - 15.09.2023 19:58

Thanks Man

Ответить
@DARKxDANI47
@DARKxDANI47 - 05.09.2023 21:44

Love you man

Ответить
@thejassuresh4852
@thejassuresh4852 - 05.01.2023 12:26

Actually I tried out with the same syntax but when I checked it out in the rdbms it is still showing the record which was apparently deleted!

Ответить
@AdamCraftPC1234
@AdamCraftPC1234 - 09.06.2022 05:23

Is it possible to change the ID of a record? so if i wanted to add a specific record to appear at a specific part of the list rather than just showing on the bottom? ( I figure changing the ID is the easiest way to do this, if not, is there another way of making that happen?)

Ответить
@Yanisja
@Yanisja - 29.03.2022 02:24

te amo < 3

Ответить
@chrisgettier6409
@chrisgettier6409 - 20.01.2022 19:26

Nice

Ответить
@jacobgold522
@jacobgold522 - 22.12.2021 09:03

anyone else here for the comp sci IA for the IB?

Ответить
@mohammadrajha5181
@mohammadrajha5181 - 19.12.2021 22:32

bro , i wanna application to see my database pls

Ответить
@jimjohnson357
@jimjohnson357 - 09.10.2021 00:46

Thanks very much for these videos, definitely buying your course. Quick question though: I'm trying to do a similar sort of database app, but I want it such that whenever a new person is added, a tab for their name appears on the root window (Successfully done). When this tab (button) is clicked, all the other details about them (last name, address etc) should be displayed in a window. Also, when you initially start the app, tabs/buttons for all people created the last time the app was used are automatically created on the root window (successfully done). The problem I'm having is that when these buttons are clicked, they open the window with all the details for the last added person instead of for the person who's name is shown on the button. To create the buttons on the root window, I used a for loop which goes through all names within the database. For each name, it creates a button and adds it to row = n on the root window, before doing n=n+1, so that the next button is added to the row below. (All the buttons do come out in the correct places with the correct names). For the creation of each button, I am using: nameButton = tk.Button(root, text=current_name, command=lambda: accessUserData(current_name)) Where current_name is the string of the name of the person, and accessUserData is a separate function which displays all the other data about the person, given that you've provided the persons name as the argument. So for each cycle in the for loop which is creating the buttons, current_name is incrementally taking the value of each persons name within the database. I'm guessing my issue is that I've severely misunderstood how I should be mapping those assignments for each button in the for loop, but I can't figure out what I should be doing. I'm also suspecting this design I'm using would be frowned upon by those who practice good code, but really hoping you can help nonetheless!

Ответить
@mee8963
@mee8963 - 09.06.2021 09:06

Is it works if the query inside execute are in small case..?

Ответить
@narutouzomaki2565
@narutouzomaki2565 - 20.05.2021 02:42

Amazing series on Tkinter 🔥 🔥

everything is working fine but there is some issue in my query label.
Can you provide the code of this video?

Ответить
@markgaje3589
@markgaje3589 - 01.05.2021 08:06

Is there any way that I can select and delete a record from a Tree View and it will include deleting also the record from the sqlite3 database?

Ответить
@user-sf4uw5wp6e
@user-sf4uw5wp6e - 06.04.2021 15:34

Really, thank you

Ответить
@jaymz5800
@jaymz5800 - 27.03.2021 20:11

I always get this "_tkinter.TclError: bad screen distance "10 0"" :(

Ответить
@anggipermana2869
@anggipermana2869 - 07.02.2021 10:48

Why I still error, appear "indentation error :unexpected indent , "{"

Ответить
@ptinting4everyone739
@ptinting4everyone739 - 24.01.2021 18:33

it give me sqlite3.OperationalError: no such table: addresses, i downloaded your code from Github! any Suggestions

Ответить
@abdulshakoor4685
@abdulshakoor4685 - 09.12.2020 13:09

share create video for Desktop application Master Detail form in Python - Like (Sales Order From , Purchase Order Form)

Ответить
@consultmohamedgamal5643
@consultmohamedgamal5643 - 01.12.2020 01:40

pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000')
A mistake appears to me when adding
Please help

Ответить
@consultmohamedgamal5643
@consultmohamedgamal5643 - 01.12.2020 01:38

Dear Sir
Thank you for the wonderful effort

Ответить
@Raxer98
@Raxer98 - 23.11.2020 15:56

What's the different between padx pady and ipadx ipady

Ответить
@MrSpatel12
@MrSpatel12 - 22.11.2020 16:58

How to get a delete button next to each entry?

Ответить
@Torment_NFS
@Torment_NFS - 09.11.2020 23:20

Hi John I'm making my own database app. I need a bit of help and the code is very similar to the code in this video,
Error message: line 82, in delete cursor.execute("DELETE from links WHERE oid = " + delete_box.get())

sqlite3.OperationalError: incomplete input

I've been trying to figure it out for at least 2 days now and still can't figure it out so I turned to you
Thank you in advance. Keep up the amazing work🏆🏆🏆👍👍👍.

Code:
from tkinter import *
import sqlite3 as sql
import time as t
import random as r
from PIL import ImageTk as ITk, Image as I
import webbrowser as wb

wn = Tk()
wn.title("Link Saver")
wn.configure(bg="slategray1")
wn.geometry("300x430")
wn.iconbitmap('LS.ico')

connection = sql.connect('links.db')

cursor = connection.cursor()

cursor.execute("""CREATE TABLE IF NOT EXISTS links (
link_1
)""")

def submit():

connection = sql.connect("links.db")

cursor = connection.cursor()

cursor.execute("INSERT INTO links VALUES (:link_1)",
{
"link_1": Link_Entry.get()
})

connection.commit()

connection.close()

Link_Entry.delete(0, END)

def query():

connection = sql.connect("links.db")

cursor = connection.cursor()

cursor.execute("SELECT *, oid FROM links")
records = cursor.fetchall()

def callback(url):
wb.open_new(url)

print_records = ""
window = Toplevel()
window.title("RECORDS")
window.geometry("355x700")
window.iconbitmap('LS.ico')
window.configure(bg="slategray1")
delete_box = Entry(window, width=30, relief=SOLID, fg="black")
delete_box.grid(row=20, column=1, ipadx=10)
delete_box = globals
delete_box_label = Label(window, text="Select ID", relief=SOLID)
delete_box_label.grid(row=20, column=0)
delete_button = Button(window, text="DELETE RECORD", command=delete, bg="red3", activebackground="red", fg="black", height=2, relief=SOLID)
delete_button.grid(row=21, column=0, columnspan=2, pady=10, padx=10, ipadx=120)
for record in records:
print_records += str(record[0]) + " " + str(record[1]) + "\n"

query_label = Label(window, text=print_records, bg="slategray1")
query_label.grid(row=1, column=0, columnspan=3)

connection.commit()

connection.close()

def delete():
connection = sql.connect("links.db")

cursor = connection.cursor()

delete_box = Entry(wn, width=30, relief=SOLID, fg="black")
delete_box.grid(row=20, column=1, ipadx=10)

cursor.execute("DELETE from links WHERE oid = " + delete_box.get())

delete_box.delete(0, END)

connection.commit()

connection.close()

def open_window():
window2 = Toplevel()
window2.title("INFO")
window2.iconbitmap('LS.ico')
window2.configure(bg="slategray1")
label1 = Label(window2, text="LinkSaver is used for storing and remembering links.", bg="slategray1")
label1.grid(column=0, row=0)
label2 = Label(window2, text="How To Use:", bg="slategray1")
label2.grid(column=0, row=1)
label3 = Label(window2, text=" 1. Copy your link into the entry box.", bg="slategray1")
label3.grid(column=0, row=2)
label4 = Label(window2, text=" 2. Press on the SAVE button.", bg="slategray1")
label4.grid(column=0, row=3)
label5 = Label(window2, text=" 3. Go to the folder where LinkSaver is in and look for a file called links.db.", bg="slategray1")
label5.grid(column=0, row=4)
label6 = Label(window2, text=" 4. Open links.db and your links will be inside or click on SHOW RECORDS.", bg="slategray1")
label6.grid(column=0, row=5)

LinkSaver = ITk.PhotoImage(I.open("LinkSaver.gif"))
LinkSaver_Label = Label(image=LinkSaver, relief=SOLID)
LinkSaver_Label.grid(column=0, row=0)

blank = Label(wn, bg="slategray1")
blank.grid(column=0, row=2)

Info_Button = Button(wn, bg="white", text="INFO", width=34, height=1, activebackground="black", activeforeground="white", relief=SOLID, command=open_window)
Info_Button.grid(column=0, row=3)

blank = Label(wn, bg="slategray1")
blank.grid(column=0, row=4)

Link_Entry = Entry(wn, width=41, relief=SOLID)
Link_Entry.grid(column=0, row=5, padx=28)

blank = Label(wn, bg="slategray1")
blank.grid(column=0, row=6)

Save = Button(wn, bg="white", text="SAVE", width=34, height=1, activebackground="black", activeforeground="white", relief=SOLID, command=submit)
Save.grid(column=0, row=7)

blank = Label(wn, bg="slategray1")
blank.grid(column=0, row=8)

query_button = Button(wn, text="SHOW RECORDS", command=query, bg="white", activebackground="black", activeforeground="white", height=1, relief=SOLID)
query_button.grid(row=9, column=0, columnspan=2, ipadx=74)

blank = Label(wn, bg="slategray1")
blank.grid(column=0, row=10)

while True:
zero = 0
t.sleep(zero)

wn.mainloop()

Ответить
@kadjenFX
@kadjenFX - 12.10.2020 15:20

Thank you John !

Ответить
@parsabahrambeik4381
@parsabahrambeik4381 - 03.10.2020 15:37

Hi, thank you very much for your video.

Ответить
@nowybopes
@nowybopes - 28.09.2020 18:39

What could I do to update oids' when I delete a record? I mean, when there are 3 records and I'll delete the 2nd one, there will be 2 records with oid 1 and 3. I need to automatically update oids' to 1 and 2. Is there any easy way to implement it?

Ответить
@musakayasimp6456
@musakayasimp6456 - 10.08.2020 10:57

or can you just give the whole code so i can try to fix it myself and thank you again you really are an amazing person

Ответить
@musakayasimp6456
@musakayasimp6456 - 09.08.2020 18:52

hello sir i am facing a problem all did is that i removed zipcode and and changed the text boxes and labels like the address to email and other stuff

and i didnt make it only print the f_name and l_name I made it print all the information and then when i closed the app and returned after 2 hours they gave me this error:
IndexError: tuple index out of range
why what did i do wrong??

Ответить
@FunnyAI953
@FunnyAI953 - 06.08.2020 09:49

it doesnt work why? the terminal shows no errors still the record is not deleted

Ответить
@FunnyAI953
@FunnyAI953 - 06.08.2020 08:58

i like ur intro

Ответить
@akshaysaxena481
@akshaysaxena481 - 06.07.2020 19:11

You are just amazing 🔥🔥🔥

Ответить
@danielchipper6781
@danielchipper6781 - 05.07.2020 19:21

How do you use the .get() function to select a item to delete without it being a label but just as an item in the database?

Ответить
@generalpinochet9821
@generalpinochet9821 - 26.06.2020 08:13

can you delete by name? for example, you make a variable called name,the user enters the name, and you can do c.execute("DELETE from adresses WHERE prodname="+name)

Ответить
@michelnaouss748
@michelnaouss748 - 21.06.2020 18:29

Is it possible to make the same program by writing to a file, and then printing what's added?

Ответить
@gyothirramaadityap1964
@gyothirramaadityap1964 - 20.06.2020 08:12

seems like getting crazy is adding tab :):)

Ответить
@chiefp7298
@chiefp7298 - 14.06.2020 23:48

"What happened in Vegas stays in Vegas "

Ответить
@iamdav13
@iamdav13 - 13.05.2020 23:49

Hi. Is it possible to delete a specific word(every time it will be another word ) instead of primaryKey, that is given from input in the box "delete"?

Ответить
@bobbobster9793
@bobbobster9793 - 09.05.2020 15:09

Last videos: Sorry for my typings, its friday in Vegas.... This video: its monday morning, u gotta bear with me... Haha, Im waiting for the next days ;) Good videos btw!! keep it up!

Ответить
@tsumi1604
@tsumi1604 - 21.04.2020 10:38

when I try to it, but not with oid with f_name it says no column
c.execute("DELETE FROM addresses WHERE f_name="+delete_box.get())
the output shows "no such column as john"
what to do master?

Ответить
@arulxaviervm3187
@arulxaviervm3187 - 21.03.2020 18:24

which software are you using for recording your screen and face(without background)

Ответить
@pietromarro4540
@pietromarro4540 - 03.02.2020 18:26

how can i clear my output on label?

Ответить
@fvefa
@fvefa - 23.01.2020 15:18

Clear and nice

Ответить
@mellie00
@mellie00 - 15.01.2020 11:07

For some reason my program keeps freezing whenever I press the delete button to try and delete a record. Any idea why?

Ответить