title: Executing stored procedures in sqlalchemy
body: <p>I am using a raw_connection in sqlalchemy to execute some SQL that runs a stored procedure.</p>
  
  <p>the stored proc selects a parameter ID at the end.
  How can I catch this ID?</p>
  
  <p>the python code is:</p>
  
  <pre><code>import sqlalchemy as sa
  
  SQLCommand = """
      DECLARE @Msg varbinary(max) = CAST(%s AS varbinary(max) )
      EXECUTE dbo.usp_procedure @Type = 32, @header = %s, @store = @Msg
      """ % (Datacontent, var)
  
  
  Engine = sa.create_engine(connection_string)
  Connection = Engine.raw_connection()
  cursor = Connection.cursor()
  cursor.execute(SQLCommand)
  return_key = list(cursor.fetchall())
  Connection.commit()
  Connection.close()
  </code></pre>
  
  <p>I thought return_key would contain the return code from usp_procedure but it errors out and I get:</p>
  
  <pre><code>No results.  Previous SQL was not a query.
  </code></pre>
  
  <p>The procedure has as a final step:</p>
  
  <pre><code>SELECT @ParamID
  </code></pre>
  
  <p>I want to be able to read this code back in my python code</p>