This could be very basic question. I'd like to validate a variable is type of cx_Oracle.OracleCursor, so I tried a couple of trials but all failed:
import cx_Oracle
def execute_sql(cursor):
"""Execute a SQL using cursor(cx_Oracle.OracleCursor)."""
if not cursor:
logging.error('cursor is null.')
return None # TODO: raise some exception.
# elif isinstance(cursor, OracleCursor): # failed
# elif isinstance(cursor, cx_Oracle.OracleCursor): # failed
logging.error('cursor is not OracleCursor.')
return None # TODO: raise some exception.
# ...
How can I validate the type of cursor
?
And the additional question is what exception/error is suitable for invalid type error?
Thanks for any help!