0

I am executing a stored procedure to extract a resultset:

cursor = cnxn.cursor()
query = 'EXEC [usp_PM_CalculateSLAForHelpDesk_Query_Details] @Param = {0}'.format(1111)
cursor.execute('[usp_PM_CalculateSLAForHelpDesk_Query_Details] ?', '1111') 
df= pd.read_sql(query,cnxn) 
cnxn.close()   

I have a stored procedure with one parameter. So how should I proceed to extract the result set into a data frame?

rd3n
  • 4,440
  • 1
  • 33
  • 45
  • 1
    See - for instance - https://stackoverflow.com/questions/12047193/how-to-convert-sql-query-result-to-pandas-data-structure – ElToro1966 Apr 16 '20 at 08:13

1 Answers1

0

As noted in the documentation, you can use the params= argument

query = 'EXEC [usp_PM_CalculateSLAForHelpDesk_Query_Details] @Param = ?'
data = (1111, )
df = pd.read_sql_query(query, cnxn, params=data)
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418