V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请  登录
V2EX  ›  SQLite

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

  •   013231 · 2012-06-21 01:15:25 +08:00 · 4891 次点击
    这是一个创建于 3706 天前的主题,其中的信息可能已经有所发展或是发生改变。
    "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
    然而真正的錯誤原因並不是無法打開數據文件, 而是無法創建日誌文件.
    关于   ·   帮助文档   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2365 人在线   最高记录 5497   ·     Select Language
    World is powered by solitude
    VERSION: · 44ms · UTC 06:09 · PVG 14:09 · LAX 23:09 · JFK 02:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.