Postgresql While Loop Exit In Python Program A Control Must Be Associated