I answered this for someone some time ago, assuming FOUND_ROWS() is local to a MySQL session (note this is not the same thing as a SQLAlchemy session though typically these map in a 1-1 fashion) there should be no issue, as long as you are using each connection in just one application thread at a time (and if you are using ORM sessions, using each Session in just one application thread at a time). Also of course on that one Session / Connection you need to make sure to query FOUND_ROWS() immediately after your query.

if you need this to be local to a cursor, you'd need to drop into direct connection / cursor access see http://docs.sqlalchemy.org/en/latest/core/connections.html#working-with-raw-dbapi-connections but I have a feeling this is not necessary.


On 05/23/2016 04:34 PM, James Li wrote:
Hi All,
I want to use SQL_CALC_FOUND_ROWS with my select query and use a
following SELECT FOUND_ROWS() to get the total count in sqlalchemy. But
how do I make sure /SELECT FOUND_ROWS()/ returns the correct cached
value in the case of *concurrent* queries of /select
SQL_CALC_FOUND_ROWS/ happen? Is the total count cached somewhere in a
sqlalchemy session after /select SQL_CALC_FOUND_ROWS/ runs? Can I
control where it gets cached in my code?

Thanks!
-james

--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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