COMP3311 20T3 The University of New South Wales Database Systems
COMP3311 Database Systems
20T3
[Instructions] [Notes] [Database] [Course Website] [Cheat Sheets]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8] [Q9] [Q10] [Q11] [Q12] Question 7 (10 marks)
Write a Python/Psycopg2 script that uses data from the footy database to produce a summary report on a player’s career. The player is supplied as a command-line argument and needs to exactly match the name as stored in the database (the whole name, with matching upper/lower case).
There are multiple players in the database who share names. None of the test cases will use these players, so you can assume that the supplied name matches 0 or 1 players.
The script should print one line for each match they played where they scored at least one goal; the line should contain where they played, what date and how many goals they scored. Matches should be shown in chronological order. The script should also count the number of matches played, the total goals scored and produce a summary line at the, which includes the name of the team/country they played for. The examples bewlow show the expected output format:
$ ./q7
Usage: ./q7 PlayerName
$ ./q7 “Bugs Bunny”
No such player
$ ./q7 ‘Michael Baumann’
played in Eindhoven on 2000-02-06 and scored 1 goal played in Lyon on 2001-07-21 and scored 1 goal played in Seoul on 2001-10-04 and scored 1 goal played in Firenze on 2002-10-27 and scored 1 goal played in Linkoping on 2003-11-03 and scored 1 goal played in Dortmund on 2005-03-28 and scored 1 goal played in Munich on 2005-10-20 and scored 1 goal played in Madrid on 2007-08-12 and scored 1 goal Summary: played for Germany, 56 matches, 8 goals
There are more examples in the tests/*.expected files. Instructions:
Put the Python code in the file q7
Put any Python helper functions in this file as well
Place any helper views or PLpgSQL functions in the q7.sql file Load any SQL code via: psql footy -f q7.sql
Test it via: ./q7 ‘Michael Baumann’
Check it using: sh check q7
Submit it using: give cs3311 sample_q7 q7.sql q7 or
End of Question
Webcms3