如果需要寫入數據, 不僅數據文件要有寫入權限, 數據文件所在的目錄也要有寫入權限

2012-06-21 01:15:25 +08:00
 013231
"When a process wants to change a database file (and it is not in WAL mode), it first records the original unchanged database content in a rollback journal. The rollback journal is an ordinary disk file that is always located in the same directory or folder as the database file and has the same name as the database file with the addition of a -journal suffix. The rollback journal also records the initial size of the database so that if the database file grows it can be truncated back to its original size on a rollback."
所以呢, 如果數據文件所在的目錄沒用寫權限, journal文件無法創建, 就無法寫入數據了.

在Python sqlite3 Package中, 會拋出一個頗有誤導性的Error:
OperationalError: unable to open database file
然而真正的錯誤原因並不是無法打開數據文件, 而是無法創建日誌文件.
被這個問題折騰了半天...
5256 次点击
所在节点    SQLite
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/40127

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX