Files and databases · GCSE · OCR J277 2.2.3, AQA 8525 3.7.2 · about 20 min
Queries across two tables; INSERT, UPDATE and DELETE, and the robot logging its own runs.
[1 mark]In SELECT robots.name, runs.cm FROM runs, robots WHERE runs.robot_id = robots.robot_id, what does the WHERE condition do?
[1 mark]Which statement adds a new record?
[1 mark]What does DELETE FROM runs do with no WHERE?
[1 mark]Complete the statement to change Ada's colour to purple: ______ robots SET colour = 'purple' WHERE name = 'Ada'
[1 mark]Why pass values to a query with ? placeholders instead of joining text into the SQL?
Using logbook.open_db(): drive forward 35 cm and insert it as run 7 for robot 2 (Bolt), task wall, with the distance the robot actually covered (position(), rounded to 1 decimal place) and its time. Update run 3's task to ramp. Delete run 5. Then, with one query across both tables, print every run by Bolt, in run order, as run 3 ramp 38.0.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() import logbook db = logbook.open_db()
Plan your program here, then type it in and press Run.
? placeholder.