use fetchone instead of iterating over cursor