On Friday, 13 April 2012 15:26:48 UTC+2, Massimo Di Pierro wrote:
>
> This has nothing to do with it.
>
> Anyway, recent version of web2py have automatic reconnect, if that is what 
> you are asking.
>
>
Here is an example of what I wanted to do  and which did not work in the 
past but I see it is now working. To me that is important progress:

db.define_table('toets',

                Field('f1'),

                Field('f2'))


Then in Postgresql: 

ALTER TABLE toets

  ADD CONSTRAINT geen_duplikaat UNIQUE(f1 , f2 );

def dup():

    f1 = 'aaaa'

    f2 = 'bbbb'



    try:

        db.toets[0] = dict(f1 = f1, f2 = f2)

    except:

        print 'This combination is already in table "toets"'



    db.commit()

    return locals()



In [6]: dup()

dup()

Out[6]: {'f1': 'aaaa', 'f2': 'bbbb'}



In [7]: dup()

dup()

This combination is already in table "toets"

Out[7]: {'f1': 'aaaa', 'f2': 'bbbb'}


Previously the connection the connection would break and a ticket issued at 
this point.

This enables me to make more use of database rules and constraints without 
having web2py do do all the work.

Regards
Johann

Reply via email to