擅长:python、mysql、java
<p>SQLite有一个<a href="https://www.sqlite.org/c3ref/update_hook.html" rel="nofollow noreferrer">^{<cd1>}</a>函数,它可以满足您的需要。</p>
<blockquote>
<p>SQLite C Interface</p>
<p>Data Change Notification Callbacks</p>
</blockquote>
<pre><code>void *sqlite3_update_hook(
sqlite3*,
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
);
</code></pre>
<blockquote>
<p>The <code>sqlite3_update_hook()</code> 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.</p>
</blockquote>
<p>不幸的是,Python sqlite模块没有公开它。。。</p>
<p>下面是一个稍微有点老套的解决方法,它可以深入到C api(来自Python代码)中来利用它:
<a href="https://stackoverflow.com/a/16920926">https://stackoverflow.com/a/16920926</a></p>