Some of the information here may be outdated, please check the book instead
[
edit]
================ start of the model mod2.py ================
#
mod2=SQLDB("sqlite://mod2.db")
mod2.define_table('tbusers',
SQLField('userid' , 'string' , length=10, required=True),
SQLField('firstn' , 'string' , length=10, required=True),
SQLField('lastn' , 'string' , length=10, required=True))
#
mod2.tbusers.userid.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(mod2, 'tbusers.userid')]
mod2.tbusers.firstn.requires=IS_NOT_EMPTY()
mod2.tbusers.lastn.requires=IS_NOT_EMPTY()
#
================ end of the model named mod2.py =============
================ start of the function named droptable ==========
def droptable():
#
# How to drop a table in web2py
#
# Given a model named mod2.py , and a table called tbusers, here's
# how you can drop the table
#
# By Sterling Hankins 05/23/2008
#
mod2.tbusers.drop()
return 'table tbusers has been dropped'