all Python 3sqlite3exception
sqlite3.OperationalError
exceptions
sqlite3 exception raised for errors related to the database's operation and not necessarily under the control of the programmer: database path not found, no such table, locked database. Subclass of sqlite3.DatabaseError.
Syntax
sqlite3.OperationalError
In student code this almost always shows up as "no such table": sqlite3.connect() does not complain about a missing file, it quietly creates an empty database, so a typo in the path becomes a missing table on the first query. The other classic is "database is locked", raised when another connection still holds an open transaction; sqlite3 waits only for the connect() timeout (5 seconds by default) before giving up. Keep it separate from ProgrammingError: this one means you fix the environment — path, schema, someone else's uncommitted transaction — not your own statement.
Examples
import sqlite3
print(issubclass(sqlite3.OperationalError, sqlite3.DatabaseError)) # → True
print(issubclass(sqlite3.OperationalError, sqlite3.Error)) # → True
con = sqlite3.connect(':memory:')
try: con.execute('SELECT * FROM missing')
except sqlite3.OperationalError as e: print(e) # → no such table: missing
See also
Open in the full glossarydocs.python.orgReport an inaccuracy