Postgresql While Loop Exit In Python What Data