2011/6/15 Michael Bayer <mike...@zzzcomputing.com>

> Assuming you're talking about the ORM.  You can of course emit the exact
> SQL you refer to any time using execute() from an engine, connection, or
> session.   The ORM works within a transaction at all times.    so an
> expression like:
>
> myobject = MyObject(id=5)
> myobject = Session.merge(myobject)
> Session.commit()
>
> will perform the equivalent steps, subject to the transaction isolation in
> effect.
>

I'm not sure this will do the trick as i don't know if the object i'm
looking for already exist or not. thus, i don't have it's id ( i don't even
know if a range of id is free or not).


>
> To lock the row during the SELECT, you can use
> query.with_lockmode(True).filter(criterion) to SELECT the row with FOR
> UPDATE, will return None if the row does not exist.
>
>  I'm not sure a lockMode is necessary. However, I'm far from being an
expert or to clearly know the internal mechanisms of DBMS, but reading the
Deadlock example in the part 12.3.3 of this page of the postgresql
documentation<http://www.postgresql.org/docs/8.1/static/explicit-locking.html>,
I thought, that sending a bunch of requests in one transaction would allow
to do it as if it was all at once, avoiding any conflicts that could occurs
if two almost identical requests were overlapping (like one executing its
first statement, the other the second ect..).

Thanks

PS: Please forgive me the amount of time i took to answer. i honestly missed
your answer. (at a point i thought my message was lost and wanted to re-post
it.)

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to