【发布时间】:2011-06-30 15:26:30
【问题描述】:
我正在浏览 web.py 0.3 教程,一旦我得到 here 我 import sqlite3 并设置 dbn='sqlite3' 但它不会工作。以前有人做过吗?
编辑 - 我想通了。我使用了约翰发布的链接中的代码并制作了以下脚本:
import sqlite3
conn = sqlite3.connect('c:\users\user\py\database')
c = conn.cursor()
c.execute('''
CREATE TABLE todo (id integer primary key, title text, created date, done boolean default 'f');
''')
c.execute('''
CREATE TRIGGER insert_todo_created after insert on todo
begin
update todo set created = datetime('now')
where rowid = new.rowid;
end;
''')
c.execute('''
insert into todo (title) values ('Learn web.py');
''')
conn.commit()
c.close()
【问题讨论】:
-
您使用的是什么操作系统?如果不在 Windows 或 Mac 上,它是什么 Linux 发行版?此外,它是 python 2.5 还是更高版本?即使是 2.5 或更高版本,如果你不编译你的 python 支持 sqlite3,你也不会拥有它。
-
它是 2.7 32 位,我在 Windows 7 上。我也让它与 Django 一起工作,所以我很确定我有它。
标签: python database sqlite web.py python-2.7