def check_success(ODBC_obj, ret):
    if ret not in (SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA):
        if isinstance(ODBC_obj, Cursor):
            ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi)
        elif isinstance(ODBC_obj, Connection):
            ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
        else:
            ctrl_err(SQL_HANDLE_ENV, ODBC_obj, ret, False)
Validate return value, if not success, raise exceptions based on the handle
dataset/ETHPy150Open harryliu/edwin/edwinServer/site_packages/pypyodbc.py/check_success