pypyodbc
pypyodbc copied to clipboard
IndexError: list index out of range
Successfully installed pypyodbc-1.3.4
Error:
state = err_list[0][0]
IndexError: list index out of range
I am also getting this error with Version 1.3.6 File "pypyodbc.py", line 1007, in check_success ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi) File "pypyodbc.py", line 972, in ctrl_err state = err_list[0][0] IndexError: list index out of range
pypyodbc.py Version 1.3.6
Around line 944 def ctrl_err(ht, h, val_ret, ansi): etc etc
err_list = []
number_errors = 1
while 1:
ret = ODBC_func(ht, h, number_errors, state, \
ADDR(NativeError), Message, 1024, ADDR(Buffer_len))
if ret == SQL_NO_DATA_FOUND:
#No more data, I can raise
#print(err_list[0][1])
state = err_list[0][0]
err_text = raw_s('[')+state+raw_s('] ')+err_list[0][1]
etc
etc
etc
elif ret == SQL_INVALID_HANDLE:
#The handle passed is an invalid handle
raise ProgrammingError('', 'SQL_INVALID_HANDLE')
elif ret == SQL_SUCCESS:
if ansi:
err_list.append((state.value, Message.value, NativeError.value))
else:
err_list.append((from_buffer_u(state), from_buffer_u(Message), NativeError.value))
number_errors += 1
elif ret == SQL_ERROR:
raise ProgrammingError('', 'SQL_ERROR')
The while loop set err_list when ODBC_func returns SQL_SUCCESS...but if ODBC_func returns SQL_NO_DATA_FOUND without a previous SQL_SCCESS, we try to access err_list which has not been set.
According to the following, it is indicated that it was fixed in version 1.3.3...but it does not seem to be fixed. https://code.google.com/archive/p/pypyodbc/issues/42
do you have a full complete .py file to test the problem ?