Python: Number of rows affected by cursor.execute(“SELECT …)

Try using fetchone: cursor.execute(“SELECT COUNT(*) from result where server_state=”2″ AND name LIKE ‘”+digest+”_”+charset+”_%'”) result=cursor.fetchone() result will hold a tuple with one element, the value of COUNT(*). So to find the number of rows: number_of_rows=result[0] Or, if you’d rather do it in one fell swoop: cursor.execute(“SELECT COUNT(*) from result where server_state=”2″ AND name LIKE ‘”+digest+”_”+charset+”_%'”) (number_of_rows,)=cursor.fetchone() … Read more

techhipbettruvabetnorabahisbahis forumu