all Python 3sqlite3exception
sqlite3.ProgrammingError
exceptions
sqlite3 exception raised for sqlite3 API programming errors: wrong number of bindings supplied to a query, or operating on a closed Connection. Subclass of sqlite3.DatabaseError.
Syntax
sqlite3.ProgrammingError
This one is always your bug: the number of bound parameters does not match the ? placeholders (a favourite mistake is passing a bare string instead of a one-element tuple, so it gets bound character by character), you touched a Connection or Cursor after close(), or you used a connection from a thread other than the one that created it (check_same_thread defaults to True). Retrying is pointless — unlike OperationalError it will never succeed on its own; catch it only to print something readable, then fix the call itself.
Examples
import sqlite3
print(issubclass(sqlite3.ProgrammingError, sqlite3.DatabaseError)) # → True
print(issubclass(sqlite3.ProgrammingError, sqlite3.OperationalError)) # → False
con = sqlite3.connect(':memory:'); con.execute('CREATE TABLE t(a, b)')
try: con.execute('INSERT INTO t VALUES (?, ?)', (1,))
except sqlite3.ProgrammingError as e: print(type(e).__name__) # → ProgrammingError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy