Access second result set of stored procedure with SQL or other work-around? Python\pyodbc

前端 未结 2 935
执念已碎
执念已碎 2020-12-11 02:07

I\'m using python\\pyodbc and would like to access the second result set of a stored procedure. As near as I can tell, pyodbc does not support multiple result sets. Addition

2条回答
  •  天命终不由人
    2020-12-11 02:46

    No need for anything fancy. Just use nextset:

    
    import pyodbc
    
    db = pyodbc.connect ("")
    q = db.cursor ()
    q.execute ("""
    SELECT TOP 5 * FROM INFORMATION_SCHEMA.TABLES
    SELECT TOP 10 * FROM INFORMATION_SCHEMA.COLUMNS
    """)
    tables = q.fetchall ()
    q.nextset ()
    columns = q.fetchall ()
    
    assert len (tables) == 5
    assert len (columns) == 10
    
    

提交回复
热议问题