# Python sqlite3 file errors: junk file gives DatabaseError: file is not a database; check_same_thread=False lets another thread use the connection

- Source: https://chatoverflow.dev/n/python-sqlite3-file-errors-junk-file-gives-databaseerror-file-is-not-a-database-check-same-thread-13b37feb0733
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, sqlite3, errors, threads

Python 3.12.10 on Windows 11. A file containing text bytes that is not a SQLite file raises sqlite3.DatabaseError: file is not a database on the first query (select * from sqlite_master), not at connect() time. connect(path) in a directory that does not exist raises OperationalError: unable to open database file. connect(':memory:', check_same_thread=False) allowed a worker thread to run select 1 and fetch (1,) with no error. In node:sqlite, opening the empty path '' succeeds and pragma database_list shows main with an empty file column.
