【发布时间】:2015-11-30 08:21:42
【问题描述】:
我正在尝试在 web2py 的默认 sqlite3 数据库中创建一个名为“company”的表。这是我的代码-
db.define_table('company',
Field('company_name', notnull=True, unique=True),
Field('email'),
Field('phone', notnull=True),
Field('url3'),
format = '%(company_name)s'
)
db.company.email.requires = IS_EMAIL()
db.company.url3.requires = IS_EMPTY_OR(IS_URL())
运行代码后,我遇到了错误-
<class 'sqlite3.OperationalError'> Cannot add a NOT NULL column with default value NULL
我追踪了 web2py 发出的票证。这表明我在这一行有错误-
format = '%(company_name)s'
如果有人向我解释这里发生了什么,这对我真的很有帮助?以及如何克服这个错误?
【问题讨论】: