If you are using Session.connection() with the ORM, it gives you a connection 
that's part of the Session's transaction.

If you aren't working with the ORM and just have an Engine, you need to get a 
Connection then call begin() on it.

this stuff is all up there if you poke around a bit.


On Jun 23, 2011, at 5:54 PM, Wells Oliver wrote:

> Hmm, new to SQLAlchemy here, but if I want transactions, then I need
> to go the Session route, correct?
> 
> On Jun 23, 2:48 pm, Michael Bayer <[email protected]> wrote:
>> On Jun 23, 2011, at 5:08 PM, Wells Oliver wrote:
>> 
>>> W/ psycopg2, you can do a cursor.execute(query, list) where list is an
>>> actual python list of values : [1,2,3]
>> 
>>> W/ SQLAlchemy, it seems the session.execute(query, values) will only
>>> accept a dictionary for values. Am I missing something? Can I pass a
>>> list instead? Thanks.
>> 
>> I was a little surprised the docs don't refer to the fact that you should 
>> use connection() for this case, so I updated them:
>> 
>> http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.sessio...http://www.sqlalchemy.org/docs/core/connections.html#sqlalchemy.engin...
>> 
>> "If a plain string is passed, it is first converted to a text() construct, 
>> which here means that bind parameters should be specified using the format 
>> :param. If raw DBAPI statement execution is desired, use 
>> Session.connection() to acquire a Connection, then call its execute() 
>> method."
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" 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/sqlalchemy?hl=en.
> 

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

Reply via email to