Python Project: Properties Maintenance System P6
Subject: Writing a Full Application for Properties Maintenance System [Add New Property Functions]
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.]
This is Part-6 of an Application to Manage Properties Maintenance in this part we will writ a Function to Add New Property to our System.
Add New Property:
This May be the longest Function in our system, we will ask the user to Enter the Data for a New Property and then saving it to the DataBase.
Simple Validation: In this Function we will do a very simple check on the user inputs, and will keep this as simple as we can so the code will not be long. Sample on this Validation will be if the user enter [E or e] we will exit the process and stop the Function.
Code Part Sample: In asking the user to select the property Type were we are using a look-up table for the Property Types, we will use the Function def get_lookup_values(tname,t_id,key_id): were we passing the table-name, the ID column name and the ID of the data we want to retrieve. Another code part we may see is checking the user input of the p_type_id (MUST BE NUMERIC)
if (p_type_id.isalpha()):
input(‘\n You Must Enter a Numeric Value. Press any key to Try Again .. > ‘). Also we can see the part of the code that will make sure that the user did not enter the [E to Exit] (if the user enter E we will display a message then will return to the Menu-Page)p_bedrooms = input(‘\n Enter the Number of Bedrooms in the Property. [E to Exit] > ‘)
if p_bedrooms in [‘e’,’E’] :
input (‘\n You Select to Exit .. Press any Key. >’)
return
Saving the Record:
After the user Enter all the data we need we will display it on the screen and asking for a confirmation to Save the record, If the user Enter [Y] as Yes, we will use the “INSERT INTO properties_t …” SQL command to save the Record to the dataBase.
Here is a screen-shot of the all code of the Function,
![]() |
NOTE: If you Download this Part you MUST Run the Option 82 (82. Delete the Data-Base and Start Again.) from the Main Menu to do the following Updates:
- Update the properties_t Table (Adding the number of BathRooms)
- Update on create_tables Function.
- Update on insert_zero_records Function.
In Part-7 In the Next Part we will write the Function to Display/Show all the Records of the Main-Property-Table on the screen.
:: PMS Parts ::
Part 1 | Part 2 | Part 3 | Part 4 |
Part 5 | Part 6 | Part 7 | Part 8 |
..:: Have Fun with Coding ::.. 🙂
To Download my Python code (.py) files Click-Here
By: Ali Radwani
-
November 14, 2021 at 7:17 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...