Mysql While Loop Exit Python Program