unable to open database SQL Origin: Data OSI layer 7 · Application Last updated 13 Oct 2026

sqlite3.OperationalError: unable to open database file

SQLite couldn’t open or create the database file — wrong path or missing/unwritable directory.

Exact message you may see unable to open database file
Seen on: SQL

Meaning

Relative paths resolve from the working directory. The parent folder must exist and be writable.

Common causes

  • Relative path from a different working directory
  • Parent directory missing
  • No permission
  • Path with ~ not expanded

⚡ Quick fix

  1. Use an absolute path (Path(__file__).parent / "app.db")
  2. Create the directory first
  3. Fix permissions

Detailed fix by platform

Python

  1. python
    DB = Path(__file__).resolve().parent / "data" / "app.db"
    DB.parent.mkdir(parents=True, exist_ok=True)

How to diagnose

  1. Path — Absolute path?
  2. Directory — Exists and writable?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

0x80070020 — 0x80070020: The process cannot access the file because it is being used by another process (Windows)0x800700200x80070570 — Error 0x80070570: The file or directory is corrupted and unreadable (Windows)0x800705705123 — SQL Server Msg 5123: CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open the physical file (SQL)5123Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…Argument list too long — bash: /bin/rm: Argument list too long (Linux)Argument list too longdatabase or disk is full — SQLite: database or disk is full (SQLITE_FULL) (SQL)database or disk is f…FileNotFoundError — FileNotFoundError: [Errno 2] No such file or directory: 'data.csv' (Python)FileNotFoundErrormalformed database — sqlite3.DatabaseError: database disk image is malformed (SQL)malformed databaseunable to…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.