replace psycopg2.ProgrammingError with StandardError