I could not get a pg8000 connection to work (see another email) so what I
am writing involves only  the psycopg2 driver.  It might be the same for
pg8000.

At the moment it seems necessary to duplicate in the python code what the
database is doing when using constraints.

Example:  I have several tables with constraints e.g. it will not allow
duplicates of the same combination of data in two or three fields.

I would like the following to be possible:

try:
      id = db(db.<tablename>).insert(field1 = field1, field2 = field2,
field3 = field3)
except:
      id = 0


This would allow Postgresql to handle the constraint and just notify the
connection that the insert/update was not successful because of the
constraint. It is not working like this at the moment.  The connection has
to be restarted (try it on the commandline).  The result of that is that
the python code has to do a query to determine whether such a combination
already exists and only then do an insert (or update).

This a waste of resources.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Reply via email to