SQLite
013231
V2EX  ›  SQLite

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

  •  
  •   013231 · Jun 21, 2012 · 6379 views
    This topic created in 5075 days ago, the information mentioned may be changed or developed.
    "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
    然而真正的錯誤原因並不是無法打開數據文件, 而是無法創建日誌文件.
    被這個問題折騰了半天...
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5947 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 02:53 · PVG 10:53 · LAX 19:53 · JFK 22:53
    ♥ Do have faith in what you're doing.