say you have a session:
session
you can get at the engine like this:
engine = session.bind
when you deal with transaction isolation, you have to make that setting in a
*new* transaction, so commit/rollback the session first:
session.commit()
then connect:
conn =
engine.connect().execution_options(isolation_level='SERIALIZABLE')
bind it:
session.bind = conn
then do stuff
session.add(X())
session.flush()
then commit:
session.commit()
bind back to the engine:
session.bind = engine
both connections that are updating the table probably need to be on the same
SERIALIZABLE isolation. it's worth doing some experiments with a short
Python script that you run twice in two separate consoles.
On Apr 28, 2013, at 3:10 AM, sajuptpm <[email protected]> wrote:
> Hi Michael Bayer,
>
> I tried with execution_options, but getting AttributeError: 'ScopedSession'
> object has no attribute 'execution_options'.
>
> Note, In my code, I don't have access to "create_engine" and "connection"
> object, since they are defined at lower level.
>
> But I can access DBSession, since it defined as module level variable in
> model.__init_.py like DBSession = scoped_session(maker)
>
> So I am searching for the fix which can do with DBSession.
>
> ======= Code ============
>
> 1) Set Session isolation_level to READ-COMMITTED
> DBSession.execution_options(isolation_level='READ-COMMITTED')
>
> 2)
> Query and get changes committed by other transactions
>
> 3) Set Session isolation_level back to REPEATABLE-READ
> DBSession.execution_options(isolation_level='REPEATABLE-READ')
>
>
>
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.