Thank you!

I found this elderly 
thread:  
https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/8WLhbsp2nls

If injecting the SQL statements directly is still the way to go, then I’ll 
wrap the conditional insert with a table lock.

Jens


On Tuesday, December 5, 2017 at 6:00:16 AM UTC+10, Mike Bayer wrote:
>
> On Mon, Dec 4, 2017 at 2:56 PM,  <jens.t...@gmail.com <javascript:>> 
> wrote: 
> > I am now thoroughly confused. 
> > 
> > My understanding of the above conditional insert statement was that it 
> won’t 
> > persist a token if there is already a token with the same user_id and 
> > client_sig in the table. Alas, today once again I see an exception 
> > “MultipleResultsFound: Multiple rows were found for one_or_none()” and 
> two 
> > token were in the table. To requests arrived 70ms apart and it seems 
> that 
> > both were successful in creating tokens. 
> > 
> > I expected that one would “outrace” the other and one would succeed to 
> > persist the token which the other would see when its insert runs. 
> > 
> > What am I missing here? 
>
> You would need to use serializable isolation or table locks to ensure 
> two conflicting INSERT operations don't overlap, if your operation 
> depends upon SELECTing those rows after the fact. 
>
>
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: Minimal, Complete, and 
> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> > description. 
> > --- 
> > 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 sqlalchemy+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to