[DB-SIG] Error in DB-API 2.0

hme@informatik.uni-rostock.de hme@informatik.uni-rostock.de
Fri, 10 May 2002 13:50:35 +0200

You (Godefroid Chapelle) wrote:
> After reading DB-API 2.0 spec, it is not clear for me which Error class 
> should be raised when trying to reuse a primary key.
> IntegrityError seems to be the best place but DataError could also be 
> candidate.
> Your opinion ?

Primary and foreign key constraints are integrity constraints.  So, I
would raise an IntegrityError.  Even other values for non-primary key
attributes which are not satiesfying the given constraints should raise
an IntegrityError.  In general, all database updates (insert, delete,
update) raising an SQL Error caused by inapropriate values for
attributes should raise IntegrityError.  There are only a few cases
where DataError should be raised in conjunction with the processing of
SQL statements, e.g. a division by zero in SELECT or WHERE clause.

My $.02


Holger Meyer, Uni of Rostock, Dpt. of CS, DB Research Group
hm at IEEE.org, http://wwwdb.informatik.uni-rostock.de/