I am trying to pull some data from a stored proc on a sql server using python.
Here is my code:
import datetime as dt
import pyodbc
import pandas as
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 dt
import pyodbc
import pandas as pd
conn = 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 dt
import pyodbc
import pandas as pd
conn = pyodbc.connect('Trusted_Connection=yes; driver =SQL Server Native client
11.0; server = *****, database = **')
sqlSend = conn.cursor()
sqlSend.execute(f"EXEC ******** '20140528'")
conn.commint()