views:

23

answers:

1
cursor.execute("SELECT SQL_CALC_FOUND_ROWS user_id FROM...limit 5")
rows = cursor.fetchall()
...
total_rows = cursor.execute("SELECT FOUND_ROWS()") #this doesn't work for some reason.

Edit: I tried SELECT FOUND_ROWS() FROM my_table...and the numbers are funky.

A: 

Seems to work here by fetching the result for the second cursor:

cursor.execute("SELECT SQL_CALC_FOUND_ROWS user_id FROM...limit 5")
rows = cursor.fetchall()

cursor.execute("SELECT FOUND_ROWS()")
(total_rows,) = cursor.fetchone()
Romuald Brunet