On Jun 25, 2010, at 10:53 PM, Yang Zhang wrote:
> On Fri, Jun 25, 2010 at 6:42 AM, Michael Bayer <[email protected]>
> wrote:
>>
>> On Jun 25, 2010, at 3:27 AM, Yang Zhang wrote:
>>
>>> How do I get the ORM to use locking selects when I do a
>>> Session.query()? E.g., select for update, or select for share
>>> (PG)/select lock in share mode (MySQL). I know this is possible using
>>> the lower-level SQL expression library. Thanks in advance.
>>
>> use query.with_lockmode(). The argument is passed down to the "for_update"
>> argument of select().
>>
>> --
>> 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.
>>
>>
>
> Thanks. Is there some way to have sqlalchemy always attach *at least*
> a "for share"/"lock in share mode" when issuing queries?
send query_cls to the sessionmaker() function:
from sqlalchemy.orm.query import Query
def query(*arg, **kw):
return Query(*arg, **kw).with_lockmode(...)
sess = sessionmaker(query_cls=query)
will probably kill your performance tho doing all those locks
> --
> Yang Zhang
> http://yz.mit.edu/
>
> --
> 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.