database - How to get SQLite result/error codes in Python -


how (extended) result/error code sqlite query in python? example:

con = sqlite3.connect("mydb.sqlite") cur = con.cursor()  sql_query = "insert user values(?, ?)"      sql_data = ("john", "macdonald")  try:     cur.execute(sql_query, sql)     self.con.commit()  except sqlite3.error er:     # extended result code here 

now suppose first column should unique , there database entry "john" in first column. throw integrityerror, i'd know sqlite result/error code stated on http://www.sqlite.org/rescode.html#extrc. want know, because want take different action different errors.

currently, can't error codes through python's sqlite3 module. per https://www.sqlite.org/c3ref/errcode.html, c api exposes basic error codes, extended error codes, , error messages through sqlite3_errcode, sqlite3_extended_errcode , sqlite3_errmsg respectively. however, searching cpython source reveals that:

while feature you're asking useful (indeed, need right debugging , frustrated absence), doesn't exist right now.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -