ying zhang <[email protected]> wrote:
>
>
> I'm confused with how Query.with_lockmode('update') works in sqlalchemy.
> My code is in attachment.
> For testing, I start test.py in 1st terminal, then start test.py in 2nd
> terminal.
> so the 2nd termial will read the data modified by 1st test.py.
> But the 2nd terminal's output contains L42 in test.py.
> It means the 2nd test.py select x for update is still a 'snapshot read'.
> In my opinion, the variable 'locking_u' should be the one changed by 1st
> terminal, locking.name should be 'aa'.
> Because it's [current read] in 'select x for update' mysql sentences.
> And mysql Isolation level is RR.
Without getting into specifics as these MySQL transaction isolation cases
are intricate to work with, SQLAlchemy is just emitting SQL on the
transaction as you can see with echo=True. So you first need to ensure that
the exact sequence of steps you’re doing work in isolation; that is, type
the commands out by hand on terminal 1 and terminal 2; then when you run
this script, ensure the sequence of commands emitted is the same as well as
their syntax.
Also, a much better way to ensure the timing here instead of timing things
between two consoles, put two Session() objects into a single script, and
just run steps on each Session in the correct sequence. You can step through
with echo=True and pdb.set_trace() and ensure that each command is emitted
and has the expected behavior.
> My test table is as below:
> mysql> select * from user_test;
> +----+------+
> | id | name |
> +----+------+
> | 1 | a |
> | 2 | b |
> | 3 | c |
> | 4 | NULL |
> +----+------+
>
>
> Thank you so much if you can understand and help me.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
> <test.py>
--
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.
For more options, visit https://groups.google.com/d/optout.