SQLite result count
Archived from the original blog (2011). Links and product details may be out of date.
To fetch the number of SQLite results before iterating over sqlite3_step calls, first run a query on the count. Such as this statement to count the number of 'x' items in table. The first result column will contain the count.
SELECT count( index ) FROM table WHERE item=x