Filter Products by Price
Intermediate · Write the code · from Python SQLite: Build and Query Databases Without a Server
From the lesson: Python SQLite: Build and Query Databases Without a Server
Every app needs to store data somewhere. A to-do list needs to remember your tasks. A contacts app needs to save names and phone numbers. You could write everything to a text file, but what happens when you need to find all contacts in a specific city, or delete tasks older than a week?
Read the lessonCreate a products table with columns id (INTEGER PRIMARY KEY AUTOINCREMENT), name (TEXT), and price (REAL). Insert these products: Laptop (999.99), Mouse (29.99), Keyboard (79.99), Monitor (349.99), Webcam (59.99). Then use a WHERE clause to select and print only products that cost less than 100, in the format name: $price.
More SQLite exercises
- Create a Students TableIntermediate
- Predict the Query ResultIntermediate
- Manage an InventoryIntermediate
- Fix the SQL Injection BugIntermediate
- Build a Contact BookAdvanced
All Python exercises · 50 practice problems · Standard Library Essentials quiz