Selection and Sorting in Order
This Tutorial's Database: spicy.db
spicy.dbname
maxSHU
inventory
Sorting by Inventory from most to least number of items
SELECT *
FROM hotpeppers
ORDER BY inventory DESC# Python w/ SQLite
import sqlite3
connection = sqlite3.connect("spicy.db")
cursor = connection.cursor()
query = '''
SELECT *
FROM hotpeppers
ORDER BY inventory DESC
'''
result = cursor.execute(query)
print(f"Our wanted pepper data: {result.fetchall()}")
cursor.close()
connection.close()Exercise
Last updated