From d630b8457a1d29b7a1354ccc6d5e2956eea865f6 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sat, 28 May 2022 10:07:07 +1000 Subject: [PATCH] Handle dead-connection errors for users of python-oracledb The major release of cx_Oracle after 8.3 was renamed python-oracledb. Until SQLAlchemy natively supports this namespace, to use python-oracledb instead of cx_Oracle, user applications can add these lines in the first executed file: import sys import oracledb oracledb.version = "8.3.0" sys.modules["cx_Oracle"] = oracledb This commit checks the new dead-connection error numbers that python-oracledb generates. --- lib/sqlalchemy/dialects/oracle/cx_oracle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 4c89ed7355..a70bb78903 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -1335,9 +1335,11 @@ class OracleDialect_cx_oracle(OracleDialect): # TODO: Others ? return True - if re.match(r"^(?:DPI-1010|DPI-1080)", str(e)): + if re.match(r"^(?:DPI-1010|DPI-1080|DPY-1001|DPY-4011)", str(e)): # DPI-1010: not connected # DPI-1080: connection was closed by ORA-3113 + # python-oracledb's DPY-1001: not connected to database + # python-oracledb's DPY-4011: the database or network closed the connection # TODO: others? return True -- 2.47.3