On Nov 23, 2007, at 3:59 AM, imgrey wrote:

>
> I was thinking to change isolation level in fact.
>
> But first, I don't know how to do this with sqlalchemy, second, with
> default isolation level commits should work properly weather or not
> something were inserted or updated during commit and third, I was
> using nested transaction like this :
>
> transaction = session.begin()
> nested = session.begin_nested()
> try:
>  ..insert.. #trying to insert values to column that have UNIQUE
> constraint
> except:
>  ..update..
> nested.commit()
> transaction.commit()
>
>
> so, I'm not sure that done everything right.
>

default isolation mode settings usually dont need any changes.  we  
dont have an official API for that yet, so you can apply it to all  
connections using a custom connect() function sent to create_engine,  
or you can try setting it individually as conn = session.connection();  
conn.connection.<set isolation>.

however, if youre getting that error, you either have a concurrent  
process/thread already making an incompatible modification to the row,  
*or* your mapping is not set up properly and the update isnt even  
finding the correct rows to update....if the problem happens every  
time, then the latter case is almost certainly the issue.  you really  
should view your SQL log to get a very clear idea of whats going on  
and i doubt isolation modes are part of the solution here.

if you are getting genuine, occasional concurrent modification errors,  
you can also look into using pessimistic locking, i.e.  
query.with_lockmode(), to pre-lock rows inside a transaction and thus  
prevent conflicts from occuring on the table in question.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to