Skip to content
C

Update and Delete by ID

Mediumpython

Write functions updateprice(productid, newprice) and deleteproduct(product_id) using parameterized queries, then apply one update and one delete to a products table and print what's left.

Approach: build the products table as in the previous problem, run an UPDATE ... WHERE id = ? and a DELETE ... WHERE id = ?, then select and print the remaining rows.

Input: First line: the number of products n. Next n lines: name,price. Then: the id to update, the new price, and the id to delete.

Output: The remaining rows (after the update and the delete), each as a tuple (id, name, price).

Input (stdin)

Output

Run your code to see output here...