title: How can pandas.read_sql_query() query a TEMP table?
body: <p>I'm in the process of converting Python code over to the new SQLAlchemy-based Pandas 0.14.1.</p>
  
  <p>A common pattern we use is (generically):</p>
  
  <pre><code>connection = db.connect()  # open connection/session
  
  sql = 'CREATE TEMP TABLE table1 AS SELECT ...'
  connection.execute(sql)
  
  ... other sql that creates TEMP tables from various joins of previous TEMP tables ...
  
  sql = 'CREATE TEMP TABLE tableN AS SELECT ...'
  connection.execute(sql)
  
  result = connection.query('SELECT * FROM tableN WHERE ...')
  
  connection.close()
  </code></pre>
  
  <p>Now, once the connection is closed the TEMP tables are purged by the DB server.  However, as the final select query is using the same connection/session, it can access the tables.</p>
  
  <p>How can I achieve similar using SQLAlchemy and pd.read_sql_query() ?</p>
  
  <p>For example:</p>
  
  <pre><code>engine = sqlalchemy.create_engine('netezza://@mydsn')
  connection = engine.connect()
  
  sql = 'CREATE TEMP TABLE tmptable AS SELECT ...'
  connection.execute(sql)
  
  result = pd.read_sql_query('SELECT * FROM tmptable WHERE ...', engine)
  </code></pre>
  
  <p>yields a DB error that the TEMP table tmptable doesn't exist.  Presumably this is because passing the engine to the read_sql_query() requires it to open a new connection which has an independent session scope and hence can't see the TEMP table.  Is that a reasonable assumption?</p>
  
  <p>Is there a way to work around that?  (passing the connection to read_sql_query() isn't supported)</p>
  
  <p>(I know that I can concatenate the SQL into a single string with ; separating the statements, but this is a simplification of the actual situation where the TEMP tables are created by a multitude of functions which call others nesting 3-4 deep. So, to achieve that would require implementing a layer than can coalesce the SQL across multiple calls before issuing it, which I'd rather avoid implementing if there is a nicer way)</p>
  
  <p>Using -<br/>
  Pandas: 0.14.1<br/>
  sqlalchemy: 0.9.7<br/>
  pyodbc: 3.0.6<br/>
  Win7 x86_64 Canopy Python distribution (Python 2.7.6)<br/>
  Josh Kuhn's Netezza SQLAlchemy dialect from <a href="https://github.com/deontologician/netezza_sqlalchemy">https://github.com/deontologician/netezza_sqlalchemy</a></p>