Objective
Create a Python program that selects, with a WHERE query, the products that cost at least a minimum price. Use an in-memory database with the sqlite3 module (sqlite3.connect(":memory:")).
Instructions
- Create the table
productswith the columnsproduct(text) andprice(integer). - Read
nand thennlines withproduct price. Then read the minimum price. - Run
SELECT ... WHERE price >= ?with the minimum as a parameter?. Sort from most to least expensive and, in case of a tie, by name. - Show each result as
product: priceand at the endFound: k.
4
pan 2
leche 3
queso 8
vino 12
5
vino: 12
queso: 8
Found: 2
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise