2024-09-28 23:20:08 发布
网友
我在sql server中有一个返回多个表的过程:
create procedure newtest as begin select 1 as a select 2 as b end
在python中,光标.说明只返回第一个列名:a
我想得到每个表中的每个列名。在
我怎么能做到呢?在
这是我的代码:
如果该命令返回多个表(即多个结果集)。您可以使用Cursor.nextset()从一个集合切换到下一个集合。在
比如:
num_tables = 0 while True: print(cur.description) # all lines of the current set ret = cur.fetchall() if len(ret) > 0: ret_list.append(ret) num_tables += 1 print(ret) # check and fetch the next set if not cur.nextset(): break
不强制结果集具有相同的列计数。例如:
结果是:
(('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)]
如果该命令返回多个表(即多个结果集)。您可以使用Cursor.nextset()从一个集合切换到下一个集合。在
比如:
不强制结果集具有相同的列计数。例如:
^{pr2}$结果是:
相关问题 更多 >
编程相关推荐