我正在浏览 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()