How do I get the (extended) result/error code from an SQLite query in Python? For example:
con = sqlite3.connect(\"mydb.sqlite\")
cur = con.cursor()
sql_query =
Currently, you can't get error codes through Python's sqlite3
module. Per https://www.sqlite.org/c3ref/errcode.html, the C API exposes basic error codes, extended error codes, and error messages through sqlite3_errcode
, sqlite3_extended_errcode
and sqlite3_errmsg
respectively. However, searching the CPython source reveals that:
While the feature you're asking for would be useful (indeed, I need it right now for debugging and am frustrated by its absence), it simply doesn't exist right now.