如何在web.py中使用随Python安装的sqlite3版本?
我正在学习 web.py 0.3 的教程,当我看到 这里 时,我使用了 import sqlite3
并设置了 dbn='sqlite3'
,但是它不工作。有没有人之前做过这个?
编辑 - 我搞定了。我用了 John 发的链接里的代码,写了以下脚本:
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()