Python: Coffee Consumption P8
Learning : Python, SQlite3, Dataset, Pandas,
Subject: Create Coffee Consumption Application.
[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]
[ IF THE IS FIRST TIME DOWNLOADING THE CODE FILE, SELECT OPTION 7 FROM MAIN-MENU TO CREATE THE DATABASE]
In this part (Part-8) of Coffee Consumption App, we will write a Function to Delete a Record from the Main Table of the Coffee Consumption System.
Deleting a record is an easy SQL command having the Table Name and the Record ID that we want to Delete. In our Function First we wil display all the Records on the screen and asking the user to Select the ID of the Record, then we will display that record (again) on the screen and ask to Confirm the action by Entering [Y].
If the user Enter [Y] the Record will be Deleted, any thing else it wil be as No and the user will returned to the Main-Menu.
Coding: We will start the Function by displaying the header, then we will call the Function that will display all the Records in the data-base.. Here is the code..
show_records(inside = ‘yes’)
and asking the user to Select the ID.
NEXT: We will check the Availability of the ID, so if the user Enter an ID that not in the Data-Base or Empty space or just press Enter we will ask to re-enter the ID again. … Here is the code ..
while True:
del_rec_id = input (‘\n\n Select the Record ID to be Deleted > ‘)
if del_rec_id in [‘e’,’E’]:
input(‘ You Select [E to Exit].. Press any Key. > ‘)
return
elif (del_rec_id ==” “) or (del_rec_id ==””) or (check_availabilty(‘coffee_con’,’c_id’, int(del_rec_id)) != None):
break
If the ID is available, then we will display the Record and will ask the user to Confirm the Delete Command. This is the code for all the Delete Function ..
![]() |
What’s Coming: In Part-9 we will Writing the Function to Edit a Coffee Record.
..:: Have Fun with Coding ::.. 🙂
Part 1 | Part 2 | Part 3 | Part 4 | Part 5 |
Part 6 | Part 7 | Part 8 | Part – | Part – |
To Download my Python code (.py) files Click-Here
By: Ali Radwani
-
September 30, 2021 at 7:12 amPython: Coffee Consumption P9 | Ali's Photography Space...
-
October 11, 2021 at 7:11 amPython: Coffee Consumption P10 | Ali's Photography Space...