sqlite3.DatabaseError:文件已加密或不是数据库 [英] sqlite3.DatabaseError: file is encrypted or is not a database

查看:22
本文介绍了sqlite3.DatabaseError:文件已加密或不是数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 sqlite 数据库并将其上传到托管.

I have created a sqlite db and uploaded it to a hosting.

然后我从我的脚本中检索它并尝试插入一些数据,但 execute() 返回一个

Then I'm retrieving it from my script and trying to insert some data, but execute() is returning a

DatabaseError(文件被加密或不是数据库).

urllib.urlretrieve('http://%s/%s' % (HOST, NAME_DB), NAME_DB)
con = sqlite3.connect(NAME_DB)
cur = con.cursor()
cur.execute('insert into log(date, count, average) values(date("now"), ?, ?)', (1, 1.2))
con.commit()
con.close()

Traceback (most recent call last):
  File "mylog.py", line 17, in <module>
    cur.execute('insert into log(date, count, average) values(date("now"), ?, ?)', (1, 1.2)) 
sqlite3.DatabaseError: file is encrypted or is not a database

如果我使用 sqlite CLI 插入数据,则不会发生此类错误.你能帮我吗?

Such error doesn't happen if I use the sqlite CLI to insert data. Could you please help me?

推荐答案

sqlite CLI 和 python sqlite API 之间的版本不匹配?我从脚本而不是 CLI 再次创建了我的数据库.现在从脚本插入和选择工作,而不是从 CLI.$sqlite -version 返回 2.8.17,而 python 版本是 2.7.3.

Version mismatch between sqlite CLI and python sqlite API? I created again my db from the script instead of the CLI. Now insert and select work from the script, but not from the CLI. $sqlite -version returns 2.8.17, while the python version is 2.7.3.

这篇关于sqlite3.DatabaseError:文件已加密或不是数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆