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')]