Recording what an app writes to SQLite: triggers or copies?

by•

Hi, I'm building RowLens, a SQLite editor for VS Code, and one feature records what your app changes: press Record, use the app, press Stop, and you get every row it added, changed, or deleted, with old and new values.

The obvious way to build that is triggers on every table. I didn't, because they change the user's database: they end up in the schema, backups, and Git, and they run inside the app's own writes.

So RowLens copies the database with SQLite's backup API when you press Record and again at Stop, then compares the two copies. Your file and your code stay untouched.

The tradeoffs I accepted:

- It shows net changes, so a value that changed and changed back doesn't appear.

- In rollback-journal mode, the app's writes wait while each copy is made, about 6 seconds per GB in my tests. WAL mode isn't affected.

When you need to know what your app wrote, what do you reach for: triggers, query logging, or before-and-after comparisons? And would you accept net changes only?

13 views

Add a comment

Replies

Be the first to reply

Have a question or a thought to share? Add a comment above to start the conversation.