A change-data-capture feed delivers every change made to a customers table. Each change is a dict:
- •
lsn — the database's log sequence number: the order the changes were committed; - •
op — "I" (insert), "U" (update) or "D" (delete); - •
id — the row's key; - •
row — for I and U, the full row after the change (a dict); for D, None.
The feed is delivered out of order, and some changes are delivered more than once (same lsn, same content).
Write apply_changes(changes) returning the table after every change has been applied in commit order: a dict mapping each live id to its row. An update replaces the whole row, and also creates the row if the id isn't in the table yet. A deleted id can be inserted again later.
Python 3.13 in your browser — the standard library plus pandas and numpy; no pip installs.