- Notifications
You must be signed in to change notification settings - Fork27
Open
Description
Describe the bug
When running sql that produces multiple result sets, theCursor.description is not updated when callingCursor.nextset(). In particular, when the first result set doesn't produce rows (like an update without output clause), it is not possible to fetch rows of the 2nd result set.
curs.execute("""update ... set ...;update ... set ... output inserted.*;""")curs.nextset()# no rows from the first setprint(rows.fetchall())# this will raise
Exception message: TypeError: 'NoneType' object is not iterableStack trace: File "/***/python3.12/site-packages/mssql_python/cursor.py", line 1821, in fetchall raise e File "/***/python3.12/site-packages/mssql_python/cursor.py", line 1818, in fetchall return [Row(self, self.description, row_data, column_map) for row_data in rows_data] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/***/python3.12/site-packages/mssql_python/row.py", line 45, in __init__ for i, col_desc in enumerate(description): ^^^^^^^^^^^^^^^^^^^^^^The provided code works using PyODBC. For that particular case, it is of course possible to split into twoCursor.execute calls. This is a reduced test-case where SQL-table variables are used, which requires the singleexecute-Call.
Further technical details
Python version: 3.12 usingmssql-python==0.13.1
SQL Server version: Azure SQL
Operating system: Ubuntu 24.04 on WSL2