bpo-16379: expose SQLite error codes and error names in sqlite3 (GH-27786)

This commit is contained in:
Erlend Egeberg Aasland 2021-08-30 20:32:21 +02:00 committed by GitHub
parent f62763d267
commit 86d8b46523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 264 additions and 32 deletions

View file

@ -24,7 +24,10 @@ while True:
if buffer.lstrip().upper().startswith("SELECT"):
print(cur.fetchall())
except sqlite3.Error as e:
print("An error occurred:", e.args[0])
err_msg = str(e)
err_code = e.sqlite_errorcode
err_name = e.sqlite_errorname
print(f"{err_name} ({err_code}): {err_msg}")
buffer = ""
con.close()