我正在浏览 web.py 0.3 教程,一旦我得到 here我 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()
最佳答案
不应该只是 dbn='sqlite'
吗?
关于python - 如何使用 web.py 安装 Python 时附带的 sqlite3 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5055526/