COMP3311 Final Exam 21T3 |
The University of New South Wales COMP3311 Database Systems Final Exam 21T3 |
Database Systems |
Write a Python/Psycopg2 script that finds unsold properties matching criteria specified on the command line.
The commnand-line arguments:
Each line of output consists of:
The properties should be listed from cheapest to most expensive. If several properties have same price, order them by property ID.
The examples below show examples the use of the script, and the precise format of the output:
# any apartment costing up to $700,000 $ python3 ./q5 Apartment 700000 0 0 0 #46428: 5/74 Leonard Avenue, Kingsford 2032, 1br, 1ba, 0car, $620000 #45874: 13/94 Jellicoe Avenue, Kingsford 2032, 1br, 1ba, 1car, $647000 #46784: 7/38 Borrodale Road, Kingsford 2032, 1br, 1ba, 0car, $695000 # two bedroom apartments up to $800,000 $ python3 ./q5 Apartment 800000 2 0 0 #46423: 18/9 Smith Street, Kingsford 2032, 2br, 1ba, 1car, $786000 # 3 bedroom, 2 bathroom, apartment up to $1million $ python3 ./q5 Apartment 1000000 3 2 0 #46106: 5/87 Fischer Street, Kingsford 2032, 3br, 2ba, 0car, $847000 #45760: 7/95 Jacques Street, Kingsford 2032, 3br, 2ba, 1car, $888000 # 3 bedroom, 2 bathroom, 1 carspace apartment up to $1million $ python3 ./q5 Apartment 1000000 3 2 1 #45760: 7/95 Jacques Street, Kingsford 2032, 3br, 2ba, 1car, $888000 # 5 bedroom, 3 bathroom house up to $2,500,000 $ python3 ./q5 House 2500000 5 3 0 #46053: 480 Bunnerong Road, Kingsford 2032, 5br, 3ba, 2car, $2114000 #46387: 7 Willis Street, Kingsford 2032, 5br, 3ba, 1car, $2192000 #46577: 9 See Street, Kingsford 2032, 5br, 3ba, 1car, $2356000
There are more examples in the tests/*.sh and tests/*.expected files.
Instructions:
Note: if the script won't execute properly as ./q5, try python3 ./q5 or whatever name the appropriate Python interpreter has in your environment.