Home > other >  Python cx_Oracle error handle error is not stable
Python cx_Oracle error handle error is not stable

Time:09-24

Try:
# Excute SQL
If (self. FinalBind=="") :
Self. ReplayCur. Execute (self finalSQL)
Subcon_logger. Debug (" Task execute SQL without para: % s "% self. The auditid)
Print (" execid: % s - replaySQL without bind "% self. The sqlexecid)
The else:
Self. ReplayCur. Execute (self. FinalSQL, self finalBind)
Subcon_logger. Debug (" Task execute SQL with para: % s "% self. The auditid)
Print (" execid: % s - replaySQL with bind "% self. The sqlexecid)
Subcon_logger. Debug (" Task execute SQL finished: % s to % s "% (self. Auditid, self. Dbversion))

Except the Exception as db_ex:
Db_ex_str=(" % s "% db_ex)
Print (" execid: % s - Oracle - Error - Message: % s "% (self. Sqlexecid db_ex_str))

The above code, according to a list of executing SQL,
If the SQL does not bind variables, perform self. ReplayCur. Execute (self. FinalSQL),
If the SQL with bind variables, the execution of the self. ReplayCur. Execute (self. FinalSQL, self. FinalBind),
If the statement execution error, the print error,

I'm at execution time, run into a situation,
SQL containing bind variables, but the self finalBind is empty,
Most of the time there will be an error, this is normal, because SQL contains bind variables, but did not provide bind variables parameters,
ORA - 01460: unimplemented or unreasonable conversion requested

But sometimes, there is no error, continue to go on the program directly, this is what reason, not

My current version are as follows:
(base) [root @ dcs7sql1 OracleSQLRunnerV4] # python
Python 3.7.3 (default, 27 Mar 2019, 22:11:17)
[GCC 7.3.0] : : Anaconda, Inc., on Linux
Type "help", "copyright", "credits" or "license" for more information.
> The import cx_Oracle
> Cx_Oracle. __version__
'7.3.0'


CodePudding user response:

There is no error, direct programs continue to go on the

This kind of circumstance can reproduce? How to find?

CodePudding user response:

Development phase, can be a LOG file, normal process also logging,

Try:
# put self first. FinalBind and self. FinalSQL are recorded in the log,

.
  • Related