Primary Keys
Every row needs a way to be identified without confusion: two students can share a name, but not an ID. The primary key is the column (or set of columns) that uniquely identifies each row. It must be unique and never NULL.
Good primary keys are stable and meaningless: an auto-numbered id is better than an email address or a phone number, because those change. In SQLite INTEGER PRIMARY KEY numbers rows automatically.
The database refuses a second row with the same key. The example shows the error, and how to catch it.
What must be true of a primary key?
Try to insert a second row with id 5 into codes and print refused when the database rejects it (catch sqlite3.IntegrityError).
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.