Recipe Difficulty: Easy
Python Version: 2.7 or 3.5
Operating System: Any
This recipe will demonstrate how to programmatically identify missing entries for a given table by using its primary key. This technique allows us to identify records that are no longer active in the database. We will use this to identify which and how many messages have been deleted from an iPhone SMS database. This, however, will work with any table that uses an auto-incrementing primary key.
To learn more about SQLite tables and primary keys, visit https://www.sqlite.org/lang_createtable.html.
One fundamental idea governing SQLite databases and their tables are primary keys. A primary key is typically a column that serves as a unique integer for a particular row in the table. A common implementation is the auto-incrementing primary key, starting typically at 1 for the...