From: Christopher Jones Date: Sat, 28 May 2022 00:07:07 +0000 (+1000) Subject: Handle dead-connection errors for users of python-oracledb X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d630b8457a1d29b7a1354ccc6d5e2956eea865f6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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. --- 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