TL;DR: If you work with dates, make sure all data that is in the database are in an harmonic pattern, or that your runtime queries are taking the diversity of patterns into consideration.
---
I landed here after facing this problem on a script that was working. For me the issue was a faulty SQL command that never ended executing, causing the timeout to reach. The timeout, as other have already mentioned, is default and increasing it to 30 in my case still showed the database locked error.
A bit of context: I use an xls as input form for some monthly accounting. My python script parses this xls, get specific cells and their values and inserto into a SQLite file so later I can generate HTML reports and other stuff I want do with it that I'm too stupid to do in Excel.
My problem was that I accidentally added a date as 03/07/20205 instead of 03/07/2025. that is dd/mm/yyyy pattern. I ran it once, Python was still able to read the value from xls and I could import the value without any issues into SQLite, but running a second time using the same input just after finished the first run caused the database locked error.
I luckly figure it out by, after the first run, popping up DBeaver, querying the table and ordered by date and finally finding a value that didn't match the others right at the beginnig of a DESC sorting on that DATE column.
I presume I have some SQL that do some time arithmatic and because the field of DATE seems to be nothing more but a TEXT field, likely that arithmatic query got lost trying to parse 03/07/20205 , hanged the connection and the next commands were never able to execute because it was processing, hence why increasing the timeout also increased the time it took to see the database locked error.
This will likely save me again in the future, so:
Hi me of the future, you messed up the spreadsheets again... learn how to type dates for once...