我在这里遵循教程http://webpy.org/docs/0.3/tutorial然后环顾网络以了解如何使用 sqlite 的待办事项列表部分并找到了这个http://kzar.co.uk/blog /view/web.py-tutorial-sqlite
我无法通过此错误。我已经搜索过,但我找不到的任何结果都对我有太大帮助。大多数人建议将引号从括号中取出。
错误
<type 'exceptions.ValueError'> at /
invalid literal for int() with base 10: '19 02:39:09'
代码.py
import web
render = web.template.render('templates/')
db = web.database(dbn='sqlite', db='testdb')
urls = (
'/', 'index'
)
app = web.application(urls, globals())
class index:
def GET(self):
todos = db.select('todo')
return render.index(todos)
if __name__ == "__main__": app.run()
模板/index.html
$def with (todos)
<ul>
$for todo in todos:
<li id="t$todo.id">$todo.title</li>
</ul>
测试
CREATE TABLE todo (id integer primary key, title text, created date, done boolean default 'f');
CREATE TRIGGER insert_todo_created after insert on todo
begin
update todo set created = datetime('now')
where rowid = new.rowid;
end;
web.py sqlite 非常新