On Dec 9, 12:02 pm, "Gaetan de Menten" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 17:20, Chris Curvey <[EMAIL PROTECTED]> wrote:
>
> > Should we be able to create a temp table in one statement, and then
> > use it in another?  I'm trying the code below, but it fails when
> > trying to execute the list_temp statement.
>
> Works fine here when I reuse the same connection (not the engine,
> which will produce a different connection on each execute). See below,
> and some details 
> at:http://www.sqlalchemy.org/docs/05/sqlexpression.html#executing
> andhttp://www.sqlalchemy.org/docs/05/sqlexpression.html#connectionless-i...
>
> Note that the session is an unrelated topic here (it is an ORM thing).
>
> > import elixir
> > from sqlalchemy import text
> > elixir.metadata.bind = "postgres://chris:[EMAIL PROTECTED]/tracking"
>
> engine = elixir.metadata.bind
> conn = engine.connect()
>
> > build_temp = text("""
> > select relname
> > into temp table foobar
> > from pg_class
> > where relkind = 'r'
> > """)
>
> > list_temp = text("""
> > select relname
> > from foobar
> > """)
>
> conn.execute(build_temp)
>
> for (relname,) in conn.execute(list_temp,):
>     print relname
>

Thanks very much.  That's tremendously helpful.
> --
> Gaëtan de Mentenhttp://openhex.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to