Skip to content

Conversation

@pmorris-dev
Copy link
Contributor

@pmorris-dev pmorris-dev commented Feb 4, 2026

  • We need a clean and reliable way to know when a SQLite database has been updated (written to). SQLite provides hooks which describe changes that have been committed
    • Which table
    • Which rowid (unless table is WITHOUT ROWID)
    • PRIMARY KEY column(s) values
    • Old and new values when applicable
  • Phase 1 includes:
    • The hooks part of the library which is the code that communicates with the SQLite C ABI. We register for:
      • Preupdate hook
      • Commit hook (fires for implicit and explicit tx commits)
      • Rollback hook
    • The TableChange and ColumnValue types and helpers
    • The broker API which takes subscriptions and manages the buffer of change events
    • Details about what's to come in the next two phases, in the README
  • Use of this feature requires that we bundle a version of SQLite which supports these hooks, which we planned to do anyway.

- We need a clean and reliable way to know when a SQLite
  database has been updated (written to). SQLite provides
  hooks which describe changes that have been committed
  - Which table
  - Which rowid
  - Old and new values when applicable
- Phase 1 includes:
  - The hooks part of the library which is the code that
  communicates with the SQLite C ABI. We register for:
    - Preupdate hook
    - Commit hook (fires for implicit and explicit tx commits
    - Rollback hook
  - The `TableChange` and `ColumnValue` types
  and helpers
  - The broker API which takes subscriptions and manages
  the buffer of change events
  - Details about what's to come in the next two phases,
  in the README
- Use of this feature requires that we bundle a version of
  SQLite which supports these hooks, which we planned
  to do anyway.
Copy link
Contributor

@jjhafer jjhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmorris-dev Looks good, just a couple minor questions.

- It's the PK that the user really needs and that might not
be the rowid
- If the table schema includes WITHOUT ROWID, the first/only
column making up the PK is returned. That's hokey. So now
we return None for rowid in that case
- Needed to add some introspection logic to find which
column(s) make up the PK and whether the table was created
using WITHOUT ROWID
@pmorris-dev pmorris-dev force-pushed the sqlite-observer-phase-1 branch from 4a929af to 060455c Compare February 5, 2026 20:42
@pmorris-dev pmorris-dev requested a review from jjhafer February 6, 2026 03:03
- We need a clean and reliable way to know when a SQLite
  database has been updated (written to). SQLite provides
  hooks which describe changes that have been committed
  - Which table
  - Which rowid
  - Old and new values when applicable
- Phase 1 includes:
  - The hooks part of the library which is the code that
  communicates with the SQLite C ABI. We register for:
    - Preupdate hook
    - Commit hook (fires for implicit and explicit tx commits
    - Rollback hook
  - The `TableChange` and `ColumnValue` types
  and helpers
  - The broker API which takes subscriptions and manages
  the buffer of change events
  - Details about what's to come in the next two phases,
  in the README
- Use of this feature requires that we bundle a version of
  SQLite which supports these hooks, which we planned
  to do anyway.
- It's the PK that the user really needs and that might not
be the rowid
- If the table schema includes WITHOUT ROWID, the first/only
column making up the PK is returned. That's hokey. So now
we return None for rowid in that case
- Needed to add some introspection logic to find which
column(s) make up the PK and whether the table was created
using WITHOUT ROWID
@pmorris-dev pmorris-dev requested a review from jjhafer February 6, 2026 13:55
@jjhafer jjhafer merged commit 9bcb0c7 into silvermine:master Feb 6, 2026
1 check passed
@pmorris-dev pmorris-dev deleted the sqlite-observer-phase-1 branch February 6, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants