Intermediate
A parameterised query
Write find_users(conn, plan). conn is an open sqlite3 connection to a database with a table users(id, name, plan). Return a list of the names (just the text) of all users whose plan equals the given one, sorted alphabetically. If nobody matches, return [].
The plan value must be passed as a parameter (a ? placeholder), not pasted into the SQL text.
What Check tests
- returns sorted names for a plan
- returns an empty list for an unknown plan
- a plan containing a quote does not break the query
- text that looks like SQL is only data
- the SQL uses a placeholder
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.