]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Handle dead-connection errors for users of python-oracledb 8065/head
authorChristopher Jones <christopher.jones@oracle.com>
Sat, 28 May 2022 00:07:07 +0000 (10:07 +1000)
committerChristopher Jones <christopher.jones@oracle.com>
Sat, 28 May 2022 00:07:07 +0000 (10:07 +1000)
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

index 4c89ed7355d27edb0d9ba56526e784eb94cc5012..a70bb78903b895a4bd19b77597c5b23563b61061 100644 (file)
@@ -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