Stop indexing rows by integer
By default, sqlite3 returns each row as a tuple. You access columns by index — fragile, hard to read, breaks when the SELECT order changes. The fix is one line:
conn.row_factory = sqlite3.RowNow each row is a sqlite3.Row — accessible by index or by column name, with a stable iteration order. It's not a dict, but dict(row) converts it cleanly when you need one (e.g., to JSON-serialize).
Tip: Set
row_factory = sqlite3.Row on every connection in production code. The runtime overhead is negligible; the readability win is enormous; the bug class 'someone added a column and shifted indices' disappears.