franz-see/Robotframework-Database-Library — Issue #18: delete_all_rows_from_table not working
Author: cleonf
Created: 2011-12-02 22:47:13+00:00
State: open

Hello,

I was trying to use the keyword "delete_all_rows_from_table" and got the following error:

21:38:48.903	TRACE	Arguments: [ u'client' ]
21:38:48.903	DEBUG	Executing : delete from client;
21:38:48.911	FAIL	AttributeError: 'int' object has no attribute 'fetchall'
21:38:48.911	DEBUG	Traceback (most recent call last):
File "D:\Development\Python27\lib\site-packages\DatabaseLibrary\query.py", line 145, in delete_all_rows_from_table
return result.fetchall()

I dig into the code and I've found the follwoing:

def delete_all_rows_from_table(self, tableName):
(...)
result = self.__execute_sql(cur, selectStatement)
if result is not None:
return result.fetchall()
self._dbconnection.commit()
(...)

Which I think it not ok (the method returns before commit the changes and "fetchall" is not member of int value from 'result'). I've made a small change and work perfectly

(...)
result = self.__execute_sql(cur, selectStatement).
if result is not None:
self._dbconnection.commit()
return result #.fetchall()
(...)

Kind Regards
cleonf