1

我正在浏览 web.py 0.3 教程,一旦我到了这里,我就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()
4

2 回答 2

2

不应该只是dbn='sqlite'吗?

于 2011-02-20T06:09:59.137 回答
1

谷歌是你的朋友。看看这个

于 2011-02-20T06:13:50.900 回答