move rowcount closer to cursor.execute