【问题标题】:How do I use the version of sqlite3 that comes with the Python installation with web.py?如何使用 web.py 安装 Python 时附带的 sqlite3 版本?
【发布时间】:2011-06-30 15:26:30
【问题描述】:

我正在浏览 web.py 0.3 教程,一旦我得到 hereimport 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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    Google 是您的朋友。看this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-05
      • 2019-12-24
      • 2018-09-18
      • 1970-01-01
      • 2016-08-17
      • 2020-01-16
      • 2021-12-03
      • 1970-01-01
      相关资源
      最近更新 更多