SQLITE_INTERRUPT
SQLiteWARNINGNotableControl Flowofficial confidence

Operation terminated by sqlite3_interrupt()

Production Risk

Low — the interrupt is intentional; handle the error and retry or report to user.

What this means

SQLITE_INTERRUPT (9) is returned when sqlite3_interrupt() is called from another thread while an SQL operation is in progress, causing it to terminate early.

Why it happens
  1. 1sqlite3_interrupt() called from a signal handler or timeout thread.
  2. 2Application-level query timeout mechanism fired.
How to reproduce

Long-running queries interrupted by a watchdog thread.

trigger — this will error
trigger — this will error
import sqlite3, threading, time
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(x)')
conn.executemany('INSERT INTO t VALUES(?)', [(i,) for i in range(100000)])

def interrupt():
    time.sleep(0.01)
    conn.interrupt()

threading.Thread(target=interrupt, daemon=True).start()
try:
    conn.execute('SELECT sum(x*x) FROM t, t, t').fetchall()
except sqlite3.OperationalError as e:
    print(e)  # interrupted

expected output

sqlite3.OperationalError: interrupted

Fix 1

Fix 2

Fix 3

Sources
Official documentation ↗

sqlite3.h — SQLITE_INTERRUPT = 9

sqlite3_interrupt()

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SQLite errors