title: How to get SQLite result/error codes in Python
body: <p>How do I get the (extended) result/error code from an SQLite query in Python?
  For example:</p>
  
  <pre><code>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:
      # get the extended result code here
  </code></pre>
  
  <p>Now suppose the first column should be unique and there is already a database entry with "John" in the first column. This will throw an IntegrityError, but I'd like to know the SQLite result/error code as stated on <a href="http://www.sqlite.org/rescode.html#extrc" rel="noreferrer">http://www.sqlite.org/rescode.html#extrc</a>.
  I want to know, because I want to take a different action for different errors.</p>