Postgres User Defined Exception Program In Python