Gee, getting a little sleepy! This has the desired effect:

test_for = 'test'
dbvalue='None'
rows=db(db.application.name==test_for).select(db.application.ALL)
for row in rows:
        dbvalue = row.name

if dbvalue == 'None':
    db.application.insert(name=test_for)

On Feb 12, 6:36 am, Christopher Steel <chris.st...@gmail.com> wrote:
> It appears that validation only works via forms. I want to insert a
> value one time but from db.py, what would be the best way to do this.
>
> I tried this, but the same value gets inserted over and over again...
>
> db.define_table('mytable',
>     Field('myfield'))
>
> db.mytable.myfield.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> 'mytable.myfield')]
>
> record_id = db.mytable.insert(myfield='myvalue')
>
> Merci!

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to