I am trying to use value of variable to be used inside MySQL query.
So, I have a first query (Sql1) to get the count (variable name = rowcount).
sql1 = ' select count(*) from ' \
       '( ' \
       ' select course_id, record_id .. ' \
       ' group by record_id '\
       ' ) src '
cursor.execute(sql1)
rowcount = cursor.fetchall()
I am trying to use the value of variable rowcount (for example 7) to be used in next MySQL query (Sql2).
For example, next query (Sql2) that I am thinking is something along this line.
sql2 = ' select course_id from '\
       ' ( select * from Courses order by course_id desc limit %s' \
       ' ) sub order by course_id asc '   
rowcount1 = ?
cursor.execute(sql2, rowcount1)
How can I pass the value of rowcount into next query where it states "rowcount1 = ? "
 
    