W liście Chris Curvey z dnia wtorek 19 sierpnia 2008:
> I'm using Pylons with SQLAlchemy & Elixir.  I need to run three SQL
> commands in sequence, but I have to be certain that all three are done
> on the same connection.  So something like this in my controller class
>
> from sqlalchemy import text
> model.metadata.bind.execute(text("set enable_seqscan=off"))
> model.metadata.bind.execute(text("select * from foo where bar
> = :bar"), bar=1)
> model.metadata.bind.execute(text("set enable_seqscan=on"))
>
If your bind object is an engine, then you can fetch a connection out of it:

conn = model.metadata.bind.connect()
conn.execute("first query")
conn.execute("second query")
...
conn.close() # returns the connection to the pool

See here: http://www.sqlalchemy.org/docs/05/dbengine.html#dbengine_connections

Note this is for 0.5, you might want to read 0.4 docs instead.
-- 
Paweł Stradomski

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to