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 =
#More info on related error can be taken by:
import sqlite3
import traceback
import sys
con = sqlite3.connect("mydb.sqlite")
cur = con.cursor()
sql_query = "INSERT INTO user VALUES(?, ?)"
sql_data = ("John", "MacDonald")
try:
cur.execute(sql_query, sql)
self.con.commit()
except sqlite3.Error as er:
print('SQLite error: %s' % (' '.join(er.args)))
print("Exception class is: ", er.__class__)
print('SQLite traceback: ')
exc_type, exc_value, exc_tb = sys.exc_info()
print(traceback.format_exception(exc_type, exc_value, exc_tb))
con.close()