5 May 2007 02:28
[psycopg] #184: ProgrammingError instead of DataError on PostgreSQL 22P02 invalid_text_representation
#184: ProgrammingError instead of DataError on PostgreSQL 22P02
invalid_text_representation
----------------------+-----------------------------------------------------
Reporter: siemer | Owner: fog
Type: defect | Status: new
Priority: normal | Milestone: PSYCOPG 2.0.6
Component: psycopg2 | Version: 2.0.2
Severity: normal | Keywords:
----------------------+-----------------------------------------------------
I don't know the current mapping from PostgreSQL errors to python
exceptions, but psycopg2 should use the pg error class as a hint:
-all errors beginning with 22 are DataErrors
-all errors starting with 23 are IntegrityErrors
See http://www.postgresql.org/docs/current/static/errcodes-appendix.html
An example:
>>> cursor.execute("select ''::int")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
psycopg2.ProgrammingError: invalid input syntax for integer: ""
>>> sys.last_value.pgcode
'22P02'
Regards,
Robert
--
--
(Continue reading)
RSS Feed