If the command returns multiple tables (i.e. multiple result sets). You can use Cursor.nextset () to switch from one set to the next.
Sort of:
num_tables = 0
while True:
print(cur.description)
ret = cur.fetchall()
if len(ret) > 0:
ret_list.append(ret)
num_tables += 1
print(ret)
if not cur.nextset():
break
Result sets must not have the same number of columns. For instance:
create procedure newtest
as
begin
select 1 as a
select 2 as b, 3 as c
end
Result:
(('a', <class 'int'>, None, 10, 10, 0, False),)
[(1, )]
(('b', <class 'int'>, None, 10, 10, 0, False), ('c', <class 'int'>, None, 10, 10, 0, False))
[(2, 3)]
source
share