On this page
sqlite3.OperationalError
Prev: sqlite3.NotSupportedError | Up: sqlite3 | Next: sqlite3.PrepareProtocol
Rel: sqlite3.adapt, sqlite3.Binary, sqlite3.Blob, sqlite3.complete_statement
Ref: docs.python.org โ sqlite3.OperationalError
Tags: #public #python3 #stdlib #sqlite3
Import
import sqlite3
from sqlite3 import OperationalError
Signature & Overview
sqlite3.OperationalError(...)
sqlite3.OperationalError class.
Methods & Attributes
OperationalError.add_note(self, note, /)โ Add a note to the exceptionOperationalError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import sqlite3
con = sqlite3.connect(":memory:")
try:
con.execute("NOT VALID SQL")
except sqlite3.OperationalError as exc:
assert "syntax error" in str(exc)
finally:
con.close()
Gotchas
- Covers SQL syntax errors, missing tables/columns, and
database is locked: Increasetimeout=onsqlite3.connect()or enablePRAGMA journal_mode=WALif you see lock contention.
REPL Inspect
from sqlite3 import OperationalError
help(OperationalError)
Linked from
Related notes
- tuts/python3/stdlib_module/sqlite3 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/NotSupportedError Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/PrepareProtocol Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/adapt Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Binary Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Blob Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/complete_statement Linked here; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib