【发布时间】:2012-07-12 16:44:15
【问题描述】:
我正在尝试修改 Google Drive 使用的两个数据库文件,以通过脚本(snapshot.db 和 sync_conf.db)重定向我的同步文件夹。虽然我可以在某些 sqlite 浏览器(不是全部)中打开文件,但我无法让 python 执行查询。我刚收到消息:sqlite3.DatabaseError: file is encrypted or is not a database
显然 google 正在数据库上使用预写日志 (WAL) 配置,可以通过对数据库运行 PRAGMA journal_mode=DELETE;(根据 sqlite.org)将其关闭,但我不知道如何如果 python 无法读取它,则对数据库运行它。
这就是我所拥有的(我尝试执行 PRAGMA 命令并提交然后重新打开,但它没有用):
import sqlite3
snapShot = 'C:\Documents and Settings\user\Local Settings\Application Data\Google\Drive\snapshot.db'
sync_conf = 'C:\Documents and Settings\user\Local Settings\Application Data\Google\Drive\sync_config.db'
sync_folder_path = 'H:\Google Drive'
conn = sqlite3.connect(snapShot)
cursor = conn.cursor()
#cursor.execute('PRAGMA journal_mode=DELETE;')
#conn.commit()
#conn= sqlite3.connect(snapShot)
#cursor = conn.cursor()
query = "UPDATE local_entry SET filename = '\\?\\" + sync_folder_path +"' WHERE filename ='\\?\C:Users\\admin\Google Drive'"
print query
cursor.execute(query)
【问题讨论】:
标签: python sqlite google-drive-api