Some of the information here may be outdated, please check the book instead
[edit]
#
# How to create a table that uses a unique constraint field ( for example a userid )
#
# By Sterling Hankins  05/25/2008
#
mod2=SQLDB("sqlite://mod2.db")
mod2.define_table('tbusers',
                SQLField('userid' , 'string' , length=10, required=True, unique=True),
                SQLField('firstn' , 'string' , length=10, required=True),
                SQLField('lastn'  , 'string' , length=10, required=True))
#
#  You can also add the following line to the model
#
mod2.tbusers.userid.requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(mod2, 'tbusers.userid')]
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.