NoneType object is not iterable error in pandas NoneType object is not iterable error in pandas sql-server sql-server

NoneType object is not iterable error in pandas


Your sproc needs

SET NOCOUNT ON;

Without this sql will return the rowcount for the call, which will come back without a column name, causing the NoneType error.


pd.read_sql() expects to have output to return, and tries to iterate through the output; that's where the TypeError is coming from. Instead, execute with a cursor object:

import datetime as dtimport pyodbcimport pandas as pdconn = pyodbc.connect('Trusted_Connection=yes', driver = '{SQL Server Native client 11.0}',server = '*****', database = '**')cur = conn.cursor()cur.execute("EXEC ******** '20140528'")

You won't receive any output, but since none is expected, your code should run without error.


import datetime as dtimport pyodbcimport pandas as pdconn = pyodbc.connect('Trusted_Connection=yes; driver =SQL Server Native client 11.0; server = *****, database = **')sqlSend = conn.cursor()sqlSend.execute(f"EXEC ******** '20140528'")conn.commint()