diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-08-30 18:32:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 18:32:21 (GMT) |
commit | 86d8b465231473f850cc5e906013ba8581ddb503 (patch) | |
tree | 38821067898cf1fb5fec7b0102e08776ce9df3fe /Doc/includes | |
parent | f62763d26755260c31c717fb396550e00eb6b2a0 (diff) | |
download | cpython-86d8b465231473f850cc5e906013ba8581ddb503.zip cpython-86d8b465231473f850cc5e906013ba8581ddb503.tar.gz cpython-86d8b465231473f850cc5e906013ba8581ddb503.tar.bz2 |
bpo-16379: expose SQLite error codes and error names in `sqlite3` (GH-27786)
Diffstat (limited to 'Doc/includes')
-rw-r--r-- | Doc/includes/sqlite3/complete_statement.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Doc/includes/sqlite3/complete_statement.py b/Doc/includes/sqlite3/complete_statement.py index cd38d73..a5c9479 100644 --- a/Doc/includes/sqlite3/complete_statement.py +++ b/Doc/includes/sqlite3/complete_statement.py @@ -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() |