Search code examples
pythonsql-serverpandasstored-procedurespymssql

Execute stored procedure in python without return


I am using this code to execute SP in python

conn = pymssql.connect(server="myServer", database="myDB", port="1433", user="myUser", password="myPwd")
pd.read_sql("EXEC MySP", conn)
conn.close()

but I get this error

File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\sql.py", line 1469, in read_query columns = [col_desc[0] for col_desc in cursor.description]

TypeError: 'NoneType' object is not iterable

after doing some research I found the cause of the error is due to no returning value coming from the SP.

ok, my SP does not have any return value and I just want to execute this SP as is.

is there anyway I can do that without having this error?


Solution

  • Thanks kjmerf

    I just added SELECT '' at the end of my SP and that fixed the problem.

    I thought there could be another function other than read_sql in pandas that might fix this but my search found non.