database is locked Unable to fetch row
-
Hi,
I have an application that dispatches jobs over network to devices on the network. Jobs are queued in a database table. My application pushes them 1 at a time to the network device. At the start of the job, the start time is written onto the job-record. At the end of the job the end time is written onto the job-record.
I have a view (derived from QTableView) linked to a QSqlQueryModel that only shows jobs that still need to start. (The start time is empty). Normally this shows 5-10 rows.
However, when I want to show all records in the jobs table (13000 records), I update the query (setQuery() without a 'WHERE' clause) not to filter on the starttime is NULL.
Then I get "database is locked Unable to fetch row" on all queries executed on the database, even on other tables.
When I restore the original query of the view (setQuery() with 'WHERE' clause) the database is locked disappears again.Is the QTableView query without 'WHERE' taking too long?
Can I tell QTableView to only fetch the first x rows?
Are there too many rows in the table? (20 years ago, I used to work on Oracle. Oracle support always said "if you don't have a million records, you don't have a database")
Is there a way to find out what is locking the database?I do access the database from multiple threads, but I took measures to provide 1 connection per thread. As long as I don't remove the 'WHERE' it's work fine...
I'm using an SQLite v3 database that I access with QSQL. QT version is v5.15 but the problem also happens in v5.12.7 LTS. The compiler is MinGW 8.1.0 64-bit on Windows10
-
Hi,
I have an application that dispatches jobs over network to devices on the network. Jobs are queued in a database table. My application pushes them 1 at a time to the network device. At the start of the job, the start time is written onto the job-record. At the end of the job the end time is written onto the job-record.
I have a view (derived from QTableView) linked to a QSqlQueryModel that only shows jobs that still need to start. (The start time is empty). Normally this shows 5-10 rows.
However, when I want to show all records in the jobs table (13000 records), I update the query (setQuery() without a 'WHERE' clause) not to filter on the starttime is NULL.
Then I get "database is locked Unable to fetch row" on all queries executed on the database, even on other tables.
When I restore the original query of the view (setQuery() with 'WHERE' clause) the database is locked disappears again.Is the QTableView query without 'WHERE' taking too long?
Can I tell QTableView to only fetch the first x rows?
Are there too many rows in the table? (20 years ago, I used to work on Oracle. Oracle support always said "if you don't have a million records, you don't have a database")
Is there a way to find out what is locking the database?I do access the database from multiple threads, but I took measures to provide 1 connection per thread. As long as I don't remove the 'WHERE' it's work fine...
I'm using an SQLite v3 database that I access with QSQL. QT version is v5.15 but the problem also happens in v5.12.7 LTS. The compiler is MinGW 8.1.0 64-bit on Windows10
@Tmalfrere said in database is locked Unable to fetch row:
database is locked Unable to fetch row
I don't use SQLite, but I think you should start by reading https://stackoverflow.com/questions/17057420/qt-sqlite-unable-to-fetch-row-database-locked.
If that does not answer, there are other hits from Googling:
database is locked unable to fetch row sqlite
.