Python User Input Error Handling In Postgresql