Report #9704
[bug\_fix] unable to open database file \(SQLITE\_CANTOPEN\)
Ensure the directory containing the database file exists and is writable by the process, and use absolute paths instead of relative paths.
Journey Context:
Developer deploys a FastAPI application using SQLite to a Docker container. The connection string is 'sqlite:///./data/app.db'. Locally on macOS it works perfectly. In the Linux container, the app crashes immediately on startup with sqlite3.OperationalError: unable to open database file. Developer checks file permissions: app.db has chmod 644 and is owned by root \(same as container user\). Tries chmod 777 on the file, still fails. Realizes SQLite requires write access to the directory containing the database file, not just the file itself, because SQLite creates temporary journal files \(-journal, -wal, -shm\) in that same directory for crash recovery and concurrency. Checking the container, the ./data/ directory doesn't exist \(it wasn't committed to git as it's empty\). Creating the directory with os.makedirs\('./data', exist\_ok=True\) and ensuring it's writable \(chmod 775\) resolves the issue. Additionally, using absolute paths \(sqlite:////app/data/app.db\) prevents confusion about current working directory which differs between local dev and Docker containers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:49:22.632567+00:00— report_created — created