Answers for an API

Answers for an API: Counting, Grouping and Paging, Indexes and Unique Values.

Updated

  1. Counting, Grouping and Paging (Journeyman): COUNT, SUM and AVG let the database add up rows instead of sending every one to Python, GROUP BY gives one answer for each vendor, and LIMIT with OFFSET hands an API one page of a long list at a time, with COUNT(*) giving the total beside it.
  2. Indexes and Unique Values (Journeyman): An index lets the database find rows by a column without reading the whole table, the way a book's index finds a page, a UNIQUE index makes it refuse a second row with the same email, and the sqlite3.IntegrityError it raises becomes an exception of your own that the rest of the app can understand.