No, 6 staff is nothing for SQLite. Three settings fix 95% of these:
conn = sqlite3.connect('routes.db', timeout=10)
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA busy_timeout=5000')- WAL mode lets readers keep reading while one writer writes. It's stored in the file, so setting it once is enough.
- busy_timeout makes a writer wait up to 5 seconds for the lock instead of failing immediately.
And check your code for a connection that opens a transaction and never commits, e.g. a global connection where a failed request left a write open. Open a connection per request and close it (Flask's g + teardown_appcontext).
check_same_thread=False is unrelated and slightly dangerous when you share one connection across threads, I'd remove it.
conn = sqlite3.connect(...)at the top of app.py ruby_t · edited