Python Project: Properties Maintenance System P2
Subject: Writing a Full Application for Properties Maintenance System
Learning : Python, Math, SQL, Logeic
[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.]
In Part-2 we will start writing the Functions in our app, to start I select the Payment Methods, this is a Look-up Table that will help the user to select come values, by defualt when you install the application and select to create the database, [in Part-1] we Insert some data all lookup-tables, So here in payment Method we have [Cash, Card, Cheque]. Our Functions will be Add New Payment Method, Edit a Payment Method and Delete a Payment Method.
Once i start writing the Edit Function, i notes that we need another two Functions to Help-up theyare: get_lookup_values(tname,t_id,key_id) and check_availabilty(dt, d_id, check_id) both not printing any thing on the screen just returning a Value.
get_lookup_values(tname,t_id,key_id) Here we pass the Table-Name, the ID field and key_id we want to return it’s Value.
check_availabilty(dt, d_id, check_id) This function will return True if the ID we send in ‘check_id’ is in the Data-Table dt.
So, let’s start with Add New Payment Method, We will ask the user to write the New Payment Method the will run the SQL command to Insert it into the data-base.. Hear is the Code ..
# Add Payment Method def add_pay_method(): os.system('clear') line2 = "Add Payment Method" header(line2, 9,14) print('\n\n List of the Payment Methods in the System .. \n') show_lookup_data('Yes' ,'pay_meth_t','pm_id') print('\n Enter a New Payment Method to the System.') print(" [E, Space or just Pressing Enter will be as 'Exit'].\n") new_pm = input(' Enter a New Payment Method > ') if new_pm in ["e","E", "", " "] : input ('\n You Select to Exit .. Press any key > ') return else: c.execute ("INSERT INTO pay_meth_t (p_method) VALUES(:p_method)",{"p_method":new_pm.capitalize()}) db_conn.commit() input('\n Done .. One record Added to the Data-Base .. Press any Key .. > ') return
Now, we will go to Edit a Payment Method that we have in the DataBase, here we will list all the Data we have on the screen, and will ask the user to Select the one to be edit, we will check the availability of the ID using the def check_availabilty(dt, d_id, check_id) Function and then [if the ID is available] we will use the def get_lookup_values(tname,t_id,key_id): function to fetch the key-value of that ID, then asking the user to Enter the New/Edited one. Here is the code..
![]() |
Last Function in this part is to Delete a Payment Method from the Databsae, here also we will display all the contents of the table on the screen, and ask the user to select the one tobe deleted, we will check the availability of the ID and ask the user to confirm the Deleting action, then will call the SQL command to delete the entry. Here is the code..
![]() |
In Part-3 In coming post we will continue writing Lookup Table Functions to Add, Edit and Delete there data.
:: PMS Parts ::
Part 1 | Part 2 | Part 3 | Part 4 |
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
-
October 24, 2021 at 7:37 amPython Project: Properties Maintenance System P3 | Ali's Photography Space...
-
October 28, 2021 at 7:12 amPython Project: Properties Maintenance System P4 | Ali's Photography Space...
-
November 2, 2021 at 7:11 amPython Project: Properties Maintenance System P5 | Ali's Photography Space...
-
November 8, 2021 at 7:10 amPython Project: Properties Maintenance System P6 | Ali's Photography Space...
-
November 14, 2021 at 7:16 amPython Project: Properties Maintenance System P7 | Ali's Photography Space...
-
November 21, 2021 at 7:11 amPython Project: Properties Maintenance System P8 | Ali's Photography Space...
-
January 5, 2022 at 7:05 amPython Project: Properties Maintenance System P9 | Ali's Photography Space...
-
February 13, 2022 at 7:07 amPython Project: Properties Maintenance System P10 | Ali's Photography Space...
-
February 20, 2022 at 7:10 amPython Project: Properties Maintenance System P11 | Ali's Photography Space...
-
February 27, 2022 at 7:12 amPython Project: Properties Maintenance System P12 | Ali's Photography Space...