Let\'s say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes.
The \"player\" process reads the database
SQLite has an update_hook function which does what you want.
SQLite C Interface
Data Change Notification Callbacks
void *sqlite3_update_hook(
sqlite3*,
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
);
The
sqlite3_update_hook()
interface registers a callback function with the database connection identified by the first argument to be invoked whenever a row is updated, inserted or deleted in a rowid table. Any callback set by a previous call to this function for the same database connection is overridden.
Unfortunately it isn't exposed by the Python sqlite module...
Here is a slightly hacky workaround that digs into the C api (from Python code) to make use of it: https://stackoverflow.com/a/16920926