SQLITE_CANTOPEN_ISDIRERRORTier 2 — Caution⚠️ MEDIUM confidenceCannot open — path is a directory
Category: File AccessVersions: 3.0+
🔴 Production Risk Error
Low — fails immediately and obviously at startup.
What this means
SQLITE_CANTOPEN_ISDIR (1038) is returned when sqlite3_open() is called with a path that points to a directory rather than a file.
Why it happens
- 1Passing a directory path instead of a file path to sqlite3_open().
- 2Path ends with "/" without specifying a filename.
How to reproduce
sqlite3_open() or sqlite3.connect() with a directory path.
trigger — this will ERROR
import sqlite3
try:
conn = sqlite3.connect('/tmp/')
except sqlite3.OperationalError as e:
print(e) # unable to open database filesqlite3.OperationalError: unable to open database file
Fix 1
Why this works
Specify a full file path including the filename: sqlite3.connect("/tmp/my.db")
Fix 2
Why this works
Check that path construction logic does not accidentally produce a directory path.
Sources
📚 Official docs: https://www.sqlite.org/rescode.html#cantopen_isdir
🔧 Source ref: sqlite3.h — SQLITE_CANTOPEN_ISDIR = 1038
Confidence assessment
⚠️ MEDIUM confidence
Stable.
See also
🔗 Related errors
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →