I have a python script which runs an SQL command on a given database. def run_sqlplus(): sqlplus = Popen(["sqlplus", "-S", "/", "as", "sysdba"], stdout=PIPE, stdin=PIPE, encoding='utf-8') sqlplus.stdin.write("set head off \nset feedback off \nset linesize 200 \nset colsep '|' \nSELECT OPEN_MODE,DATABASE_ROLE FROM V$DATABASE;") DbStatusCheckOut,DbStatusCheckErr = sqlplus.communicate() LOGGER.debug("Database Status details are : %s",DbStatusCheckOut) return DbStatusCheckOut On some databases the above script throws the following error: 2022-03-15 13:13:32,593 DEBUG [v2.py:71]: Database Status details are : SELECT OPEN_MODE,DATABASE_ROLE FROM V$DATABSE * ERROR at line 1: ORA-01034: ORACLE not available Process ID: 0 Session ID: 0 Serial number: 0 I tried to modify the code to include try and except, but it did not work with any type of exception like: except Exception, except RuntimeError or except "ORA-01034", i get the same error as stated above. python version is 2.6 cx_oracle cannot be used. What is the best way to handle this error? Continue reading...