Files and databases · GCSE · about 25 min
Log every run to a file, load the file into a table, and find the best run with SQL.
[1 mark]In the logbook, why is the file used as well as the database table?
[1 mark]logbook.csv has a header line and four runs. How many lines does the file have?
[1 mark]Which query finds the fastest run?
[1 mark]What happens to the logbook if the program opens logbook.csv with mode "w" to add a run?
Build the program from the brief. Print runs logged: <n> using SELECT COUNT(*), and fastest: run <n> at <speed> cm/s with the speed rounded to 1 decimal place, using ORDER BY. The task types 28, and starts from the four-run logbook above every time.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() import sqlite3
Plan your program here, then type it in and press Run.
runs.csv and robots.csv, and load them into two linked tables.