Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLite database table is locked error

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
SQLite "database table is locked" error

1. Is there a better place to ask this question?
2. If not:

I read that reading and writing in a sqlite table cannot be done 'at the same time' and that is why I get this error.

My code goes something like this:

Code:
$query="SELECT * FROM (bestanden) WHERE naam='$basename'  ORDER BY naam ;";
$result=$sql->unbufferedQuery($query);
$row=$result->fetch(SQLITE_ASSOC);

[...]

$query4="UPDATE bestanden SET datum='$fd' WHERE naam='$basename' ";
$result4=$sql->query($query4);

How would I avoid the error?
 
use fetchAll rather than fetch. this is an ok methodology unless your recordset is likely to be very large.
 
Could the unbuffered query be the problem? If trhe query results would be buffered, the query itself could be closed again.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Thanks both of you.'ll try this tomorrow.
The recordset is rather largish, this why I opted for unbuffered, but if this solves my problem, I think I can handle the extra data, or maybe limit it in an other way, Thanks again, I'll let you know if it worked.
 
there's no way around this. it's a file lock issue. you must release the read lock created by the select query before you engage the write lock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top