title: SQLAlchemy Execute with raw SQL containing @DECLARE local tables
body: <p>I'm stuck -- I have the following python script with SQL alchemy which I've been using quite successfully for several other purposes.</p>
  
  <pre><code>import sqlalchemy
  from sqlalchemy import MetaData
  from sqlalchemy.orm import *
  
  engine = sqlalchemy.create_engine("this line of code would provide credentials to the     database")
  connection = engine.connect()
  session = sessionmaker(bind=engine)
  result = connection.execute(sqlquery)
  
  for row in result: print row
  </code></pre>
  
  <p>Recently though I discovered that if my 'sqlquery' contains an @Declare MyTable statement I get the error:</p>
  
  <pre><code>"This result object does not return rows. "
  sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically.
  </code></pre>
  
  <p>Here is my SQL query which works fine in SSMS but will not execute when I try to execute it using SQLAlchemy</p>
  
  <pre><code>DECLARE @USER TABLE
  (
      UserID INT
      , StatsVals INT
  )
  
  INSERT INTO @USER (UserID, StatsVals)
      SELECT TOP 10 u.UserID
      , u.StatsVals
      FROM UserProfile u
  
  SELECT * FROM @USER
  </code></pre>
  
  <p><strong>Does anyone know why SQLAlchemy would be giving me this error?  What should I do to fix this?</strong></p>