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

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 122

  • @Codemycom
    @Codemycom  4 года назад +1

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips Channel:
    bit.ly/2UFLKgj bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN

  • @GurpreetSingh-fl3bw
    @GurpreetSingh-fl3bw 4 года назад +2

    I am loving the content, and honestly, I am learning a lot through your online mini-classes on RUclips. Honestly, can say that just from these videos, I am actually getting a huge foundation on python.

  • @bobbobster9793
    @bobbobster9793 4 года назад +4

    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!

    • @Codemycom
      @Codemycom  4 года назад +2

      Ha thanks bob...but this is video 21...there's like 45 more videos already published after this one. Check the playlist :-p

    • @bobbobster9793
      @bobbobster9793 4 года назад +1

      @@Codemycom , I am, I am.... need more time in a day hahaha... Im learning great things here! ... I was just building some gui stuff in pygame, but this is much easier!

  • @stevechoatie249
    @stevechoatie249 13 дней назад

    Hi John. What code would be needed to show the records when there were more than what would fit in the window? I'm assuming you could place them in another window or frame with the ability to use a scroll button. Thanks!

  • @kjn5991
    @kjn5991 4 года назад +1

    15:12 I "fixed" the formatting issue by deleting the label widget when deleting the record.
    query_label.grid_forget()

    • @Codemycom
      @Codemycom  4 года назад

      cool

    • @nova9157
      @nova9157 3 года назад +1

      thnx dude

    • @markostanojevic4739
      @markostanojevic4739 3 года назад

      can u please be precise, where di you put query_label.grid_forget(), because when i put it anywhere cmd says query_label is not defined...

    • @kjn5991
      @kjn5991 3 года назад

      @@markostanojevic4739 If you've followed the video 100% same way, then put it inside the delete method (as I originally mentioned in the comment).
      It's been over a year since I did this tutorial and now I am actually working with Angular / Typescript on a Web development job, so I don't remember every little detail.

  • @akshaysaxena481
    @akshaysaxena481 4 года назад +2

    You are just amazing 🔥🔥🔥

  • @dkallail1
    @dkallail1 5 лет назад +2

    Hi John, would you please let me know if there is a reason capitalization is used in the c.execute line of code on certain words? c.execute("DELETE from addresses WHERE oid =").

    • @Codemycom
      @Codemycom  5 лет назад +3

      It's just how SQL has always been...not sure if it's the convention (ie what everyone does because it's easier to read) or if it's actually case sensitive. Try it lowercase and see what happens :-p

  • @AdamCraftPC1234
    @AdamCraftPC1234 2 года назад

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

  • @arulxaviervm3187
    @arulxaviervm3187 4 года назад +1

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

    • @nirmaltheprogrammer510
      @nirmaltheprogrammer510 3 года назад +1

      Record screen with OBS and face with camera and edit them together

  • @consultmohamedgamal5643
    @consultmohamedgamal5643 4 года назад

    Dear Sir
    Thank you for the wonderful effort

  • @gyothirramaadityap1964
    @gyothirramaadityap1964 4 года назад

    seems like getting crazy is adding tab :):)

    • @Codemycom
      @Codemycom  4 года назад

      Sorry, not sure what you mean

    • @gyothirramaadityap1964
      @gyothirramaadityap1964 4 года назад

      @@Codemycom nothing it's just that you said let's get crazy and then changed the code to add another tab if space between two things;)

  • @IronWolf47
    @IronWolf47 Год назад

    Love you man

  • @nowybopes
    @nowybopes 4 года назад

    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?

  • @jimjohnson357
    @jimjohnson357 3 года назад

    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!

    • @jimjohnson357
      @jimjohnson357 3 года назад

      To clarify, the aim of each button created should be to run 'accessUserData' with the input argument as the name which is shown on the button. But I need to make 100+ buttons, which all do this same function, just with different input arguments and labels on the button. So I tried using the for loop, but it's ended up being such that all 100 buttons, when clicked, execute the 'accessUserData' function with the input argument as the 100th button name instead of the name they should actually represent.

    • @Codemycom
      @Codemycom  3 года назад +1

      Sorry Jim, I'm not able to help students with their projects that aren't a part of one of my courses.

  • @kadjenFX
    @kadjenFX 4 года назад

    Thank you John !

  • @musakayasimp6456
    @musakayasimp6456 4 года назад

    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??

  • @أحمدمرجان-ج6ر
    @أحمدمرجان-ج6ر 3 года назад

    Really, thank you

  • @IronWolf47
    @IronWolf47 Год назад

    Thanks Man

  • @tl3595
    @tl3595 4 года назад

    @15:12 When you delete the record and you say "It does some weird formatting". Is there any way when you delete a record for it to clear out that line completely.

    • @melnimati
      @melnimati 4 года назад +1

      The weird formatting is because the labels are being stuck one on another. And the weird formatting is because the old is still there. The right approach is not to make new labels through functions, but rather update an existing label with Label.config().

    • @dylancampbell6433
      @dylancampbell6433 3 года назад

      @@melnimati this isn't working either

  • @mellie00
    @mellie00 4 года назад +2

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

    • @Codemycom
      @Codemycom  4 года назад

      No clue...when you close your program after that happens...what does the terminal say?

  • @fvefa
    @fvefa 4 года назад

    Clear and nice

    • @Codemycom
      @Codemycom  4 года назад

      Thank you! See you around the channel!

  • @FunnyAI953
    @FunnyAI953 4 года назад

    i like ur intro

  • @mee8963
    @mee8963 3 года назад

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

  • @consultmohamedgamal5643
    @consultmohamedgamal5643 4 года назад

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

  • @markgaje3589
    @markgaje3589 3 года назад

    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?

    • @Codemycom
      @Codemycom  3 года назад +1

      yes, doing that soon

  • @iamdav13
    @iamdav13 4 года назад

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

    • @Codemycom
      @Codemycom  4 года назад

      anything is possible

  • @narutouzomaki2565
    @narutouzomaki2565 3 года назад

    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?

    • @Lennardish
      @Lennardish Год назад

      from tkinter import *
      import sqlite3
      root = Tk()
      root.geometry("400x600")
      root.title("Verjaardagen van de familie")
      # create datbas or connect to one
      #conn = sqlite3.connect('scorelijst.db')
      #create cursor
      #c = conn.cursor()
      ''' # between six single quotes you neutralize CREATE TABLE
      curs.execute("""CREATE TABLE vjdagen (
      vnaam text,
      vjdag,
      maand
      )""")
      '''
      #create kies_naam functie
      def kies_naam():
      # create datbas or connect to one
      conn = sqlite3.connect("Familie.db")
      #create cursor
      curs = conn.cursor()
      a = kies_naam_box.get()
      a = a.capitalize()
      curs.execute("SELECT * FROM vjdagen WHERE vnaam like '%{}%'".format(a))
      #curs.execute("SELECT * FROM vjdagen WHERE maand like '%{}%'".format(a))
      records = curs.fetchall()
      print_records = ''
      for record in records:
      print_records += str(record) + "
      "
      query_label = Label(root, text=print_records)
      query_label.grid(row=10, column=0, columnspan=2)
      conn.commit()
      conn.close()
      #create kies_maand functie
      def kies_maand():
      # create datbas or connect to one
      conn = sqlite3.connect("Familie.db")
      #create cursor
      curs = conn.cursor()
      a = kies_maand_box.get()
      a = a.capitalize()

      curs.execute("SELECT * FROM vjdagen WHERE maand like '%{}%'".format(a))
      #curs.execute("SELECT * FROM vjdagen WHERE maand like '%{}%'".format(a))
      records = curs.fetchall()
      print_records = ''
      for record in records:
      print_records += str(record) + "
      "
      query_label = Label(root, text=print_records)
      query_label.grid(row=13, column=0, columnspan=2)
      conn.commit()
      conn.close()
      #create submit function
      def submit():
      # create datbas or connect to one
      conn = sqlite3.connect("Familie.db")
      #create cursor
      curs = conn.cursor()
      #insert into table
      conn.execute("INSERT INTO vjdagen VALUES (:vnaam,:vjdag,:maand)",
      {
      'vnaam': vnaam.get(),
      'vjdag': vjdag.get(),
      'maand': maand.get()
      })
      conn.commit()
      conn.close()
      #clear the invoerboxes
      vnaam.delete(0,END)
      vjdag.delete(0,END)
      maand.delete(0,END)
      #create Query function
      def query():
      som = 0
      #som2 = 0
      # create datbas or connect to one
      # create datbas or connect to one
      conn = sqlite3.connect("Familie.db")
      #create cursor
      curs = conn.cursor()
      #Doorzoek de database
      curs.execute("SELECT *,oid FROM vjdagen")
      records = curs.fetchall()
      print_records = ''
      for record in records:
      print_records += str(record) + "
      "
      query_label = Label(root, text=print_records)
      query_label.grid(row=10, column=0, columnspan=2)

      print("--------------------------------------------------------")
      conn.commit()
      conn.close()
      #create invoer_boxes
      vnaam = Entry(root, width=30)
      vnaam.grid(row=0, column=1, padx=20)
      vjdag = Entry(root, width=30)
      vjdag.grid(row=1, column=1, padx=20)
      maand = Entry(root, width=30)
      maand.grid(row=2, column=1, padx=20)
      kies_naam_box = Entry(root, width=30)
      kies_naam_box.grid(row=8, column=1)
      kies_maand_box = Entry(root, width=30)
      kies_maand_box.grid(row=11, column=1)
      #create labels
      vnaam_label=Label(root, text="Voornaam")
      vnaam_label.grid(row=0,column=0)
      vjdag_label=Label(root, text="Verj_dag")
      vjdag_label.grid(row=1,column=0)
      maand_label=Label(root, text="Maand")
      maand_label.grid(row=2,column=0)
      kies_naam_box_label=Label(root,text="Welke naam zoek je? : ")
      kies_naam_box_label.grid(row=8, column=0)
      kies_maand_box_label=Label(root,text="Welke maand zoek je? : ")
      kies_maand_box_label.grid(row=11, column=0)
      #creat Submit button
      submit_btn = Button(root,text="Voeg record toe aan database", command=submit)
      submit_btn.grid(row=6, column=0,columnspan=2,pady=10,padx=10,ipadx=100)
      #Create Query Button
      query_btn = Button(root, text="Toon records", command=query)
      query_btn.grid(row=7, column=0, columnspan=2, pady=10, padx=10,ipadx=144)
      naam_btn = Button(root, text="Wiens verjaardag wil je weten ?", command=kies_naam)
      naam_btn.grid(row=9, column=0, columnspan=2,padx=2, pady=10,ipadx=97)
      mnd_button = Button(root,text="Welke maand zoek je?", command=kies_maand)
      mnd_button.grid(row=12, column=0, columnspan=2,padx=2, pady=10,ipadx=97)
      root.mainloop()

  • @musakayasimp6456
    @musakayasimp6456 4 года назад

    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

    • @Codemycom
      @Codemycom  4 года назад

      huh?

    • @musakayasimp6456
      @musakayasimp6456 4 года назад

      Can you give me the code for the database?

    • @Codemycom
      @Codemycom  4 года назад +1

      @@musakayasimp6456 Isn't it in the video?

    • @musakayasimp6456
      @musakayasimp6456 4 года назад

      @@Codemycom yes but i need it to compare so i need it for the comparing to be easier i need it as a file

    • @Codemycom
      @Codemycom  4 года назад +1

      @@musakayasimp6456 uh-huh... github.com/flatplanet/Intro-To-TKinter-RUclips-Course

  • @generalpinochet9821
    @generalpinochet9821 4 года назад

    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)

    • @Codemycom
      @Codemycom  4 года назад

      yes, but what if more than one record has the same name?

    • @generalpinochet9821
      @generalpinochet9821 4 года назад +1

      @@Codemycom luckily I am doing it for an inventory management system, where each component has a unique name with a number attached to it.

  • @michelnaouss748
    @michelnaouss748 4 года назад

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

  • @danielchipper6781
    @danielchipper6781 4 года назад

    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?

    • @Codemycom
      @Codemycom  4 года назад

      .get() only works with certain widgets, like entry boxes. Retrieving items from the database doesn't involve get.

  • @ptinting4everyone739
    @ptinting4everyone739 3 года назад

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

    • @Codemycom
      @Codemycom  3 года назад

      I suggest not downloading the code from github, but following the video and doing it all yourself. You must have missed a step somewhere.

  • @tsumi1604
    @tsumi1604 4 года назад

    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?

    • @Codemycom
      @Codemycom  4 года назад

      So you're doing it a different way than I do in the video and wondering why it doesn't work?

    • @bruceduu
      @bruceduu 4 года назад

      @@Codemycom I have the same problem as above, can you fix it? Thanks

    • @HT-dp9br
      @HT-dp9br 4 года назад

      @CHIA SHUN CHENG thanks! i was looking this

  • @mohitshrivastav2783
    @mohitshrivastav2783 4 года назад

    Pls hlp me sir. When i write:
    c.execute("DELETE from shop WHERE S.No. =" + del_box.get())
    It gives a syntax error near "=".
    Pls hlp.

    • @peeyushkumar3036
      @peeyushkumar3036 4 года назад

      Use c.execute("DELETE FROM addresses WHERE = " +delete_box.get()). Just give a space after =, and it works.

    • @mampiisaotaku
      @mampiisaotaku 4 года назад

      what is "S.No."? looks like you have change every variable name. it might be it.

  • @Raxer_th
    @Raxer_th 4 года назад

    What's the different between padx pady and ipadx ipady

    • @Codemycom
      @Codemycom  4 года назад +1

      ipadx-y are internal, the other two are external padding

    • @Raxer_th
      @Raxer_th 4 года назад

      @@Codemycom Wow! Didn't expect a very fast reply! Thanks!

  • @pranavguptaa
    @pranavguptaa 4 года назад

    I am using mysql and that statement at 14:53 didn't work there. Please help me out!!

    • @Codemycom
      @Codemycom  4 года назад

      what does the error tell you to do?

    • @pranavguptaa
      @pranavguptaa 4 года назад

      @@Codemycom It tells me that i have an error in my SQL Syntax

    • @Codemycom
      @Codemycom  4 года назад

      @@pranavguptaa Then compare your SQL code to my video code and discover what you did wrong...

    • @pranavguptaa
      @pranavguptaa 4 года назад

      @@Codemycom Ok man,thanks for help

  • @thejassuresh4852
    @thejassuresh4852 Год назад

    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!

    • @Codemycom
      @Codemycom  Год назад

      then you didn't do something right...

  • @abdulshakoor4685
    @abdulshakoor4685 4 года назад

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

    • @Codemycom
      @Codemycom  4 года назад

      I have videos that cover that in the playlist

  • @parsabahrambeik4381
    @parsabahrambeik4381 4 года назад

    Hi, thank you very much for your video.

  • @ammarb7977
    @ammarb7977 5 лет назад

    How can you select and show the record on a different window?

    • @Codemycom
      @Codemycom  5 лет назад

      Check the playlist...I have videos on opening other windows.

  • @Yanisja
    @Yanisja 2 года назад

    te amo < 3

  • @MrSpatel12
    @MrSpatel12 4 года назад

    How to get a delete button next to each entry?

    • @Codemycom
      @Codemycom  4 года назад

      what's the question? Just do it...maybe keep watching videos in the playlist for basic grid stuff...

    • @MrSpatel12
      @MrSpatel12 4 года назад

      @@Codemycom I would like to have a small delete button next to each record, so the for loop must create them, but its not possible to add a button to a string. How to solve this problem?

  • @FunnyAI953
    @FunnyAI953 4 года назад

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

    • @Codemycom
      @Codemycom  4 года назад +1

      Check your code for typos

  • @pietromarro4540
    @pietromarro4540 4 года назад

    how can i clear my output on label?

    • @Codemycom
      @Codemycom  4 года назад

      What do you mean?

    • @pietromarro4540
      @pietromarro4540 4 года назад

      @@Codemycom hello thank you for your answer, I dont understand how I can clear my output under delete record button, because my little program was slightly different, but the idea was i dont want to overwrite my output and i want "refresh" my label. I resolved this by creating a new window with output.

    • @Codemycom
      @Codemycom  4 года назад

      @@pietromarro4540 cool

    • @pietromarro4540
      @pietromarro4540 4 года назад +1

      @@Codemycom thank you for your videos!! now im working on my database and im making new windows with toplevel() , your video are very useful!!!

    • @Codemycom
      @Codemycom  4 года назад +1

      @@pietromarro4540 Awesome! Glad you're enjoying them!

  • @anggipermana2869
    @anggipermana2869 3 года назад

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

    • @Codemycom
      @Codemycom  3 года назад

      Python is tab specific. You have to use the tab key on your keyboard and it has to be exact.

  • @thechill262
    @thechill262 5 лет назад

    my results didn't tab well... hmmm

  • @mohammadrajha5181
    @mohammadrajha5181 2 года назад

    bro , i wanna application to see my database pls

    • @Codemycom
      @Codemycom  2 года назад +1

      Yeah, that's what all this does

  • @jaymz5800
    @jaymz5800 3 года назад

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

    • @Codemycom
      @Codemycom  3 года назад

      then you have a typo in your code somewhere

  • @jacobgold522
    @jacobgold522 2 года назад

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

  • @mr.wanted954
    @mr.wanted954 5 лет назад

    What did I witness at 0:00 frame? Meme potential...

  • @shubhamdayal5687
    @shubhamdayal5687 4 года назад

    Having the same UI how can we add, delete, update, things for a CSV sheet? @Codemy.com

    • @Codemycom
      @Codemycom  4 года назад

      I have a whole course on using python and excel at Codemy.com

  • @helaolange
    @helaolange 4 года назад +6

    "What happened in Vegas stays in Vegas "