Re: [sqlite] Detach says database is locked
This type of thing works with SQLite 3.6.18. I have a similar issue with 3.7. I believe the difference is that in 3.6.18, if you do a select on a main database that doesn't involve an attached database, the attached database isn't locked. In 3.7, if you do a select on the main database that doesn't involve an attached database, but there IS an attached database, the attached database is locked anyway. Then it's not possible to detach it with the open select, even though that select has nothing to do with the attached db. I don't know if this new behavior is a bug in 3.7, or is considered a fix to 3.6. Jim -- HashBackup: easy onsite and offsite Unix backup http://sites.google.com/site/hashbackup On Thu, Oct 21, 2010 at 12:21 PM, Alan Chandlerwrote: > On 21/10/10 00:35, Igor Tandetnik wrote: > > Alan Chandler wrote: > >> Further to my other post related to attaching to databases with PHP PDO, > >> I have now managed to ATTACH OK > >> > >> However, when I come to DETACH, I am getting a Database is locked error > >> when I try and execute it. > >> > >> The only thing happening to that database in between ATTACH and DETACH > >> is a single row SELECT > > > > Make sure you reset or finalize the statement (not sure how it's done in > PHP). > I believe closeCursor(); does the job. If not, I unset the variable. > > However, I have figured out the problem - which is really sad since I > can't do what I hoped - which is loop round a set of rows from a higher > level select statement ATTACHing and DETACHing to a database in turn . > Because the top level select loop is its own transaction, you can't > detach from the database which you attached in the inner part of the > loop since at that moment you are in a transaction. > > I think my way out of the problem is to pull out all the rows into a > single array, then close the transaction and interate over the array > members. Fortunately in the case its just a menu - so there probably > won't be too many items. > > > > -- > Alan Chandler > http://www.chandlerfamily.org.uk > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Detach says database is locked
On 21/10/10 00:35, Igor Tandetnik wrote: > Alan Chandlerwrote: >> Further to my other post related to attaching to databases with PHP PDO, >> I have now managed to ATTACH OK >> >> However, when I come to DETACH, I am getting a Database is locked error >> when I try and execute it. >> >> The only thing happening to that database in between ATTACH and DETACH >> is a single row SELECT > > Make sure you reset or finalize the statement (not sure how it's done in PHP). I believe closeCursor(); does the job. If not, I unset the variable. However, I have figured out the problem - which is really sad since I can't do what I hoped - which is loop round a set of rows from a higher level select statement ATTACHing and DETACHing to a database in turn . Because the top level select loop is its own transaction, you can't detach from the database which you attached in the inner part of the loop since at that moment you are in a transaction. I think my way out of the problem is to pull out all the rows into a single array, then close the transaction and interate over the array members. Fortunately in the case its just a menu - so there probably won't be too many items. -- Alan Chandler http://www.chandlerfamily.org.uk ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Detach says database is locked
On 21 Oct 2010, at 12:27am, Alan Chandler wrote: > The only thing happening to that database in between ATTACH and DETACH > is a single row SELECT If you try it without the SELECT does it work ? Does the SELECT return any results ? Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Detach says database is locked
Alan Chandlerwrote: > Further to my other post related to attaching to databases with PHP PDO, > I have now managed to ATTACH OK > > However, when I come to DETACH, I am getting a Database is locked error > when I try and execute it. > > The only thing happening to that database in between ATTACH and DETACH > is a single row SELECT Make sure you reset or finalize the statement (not sure how it's done in PHP). -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Detach says database is locked
Further to my other post related to attaching to databases with PHP PDO, I have now managed to ATTACH OK However, when I come to DETACH, I am getting a Database is locked error when I try and execute it. The only thing happening to that database in between ATTACH and DETACH is a single row SELECT I don't really understand why I can't DETACH. Can anyone give me any ideas what this could be. -- Alan Chandler http://www.chandlerfamily.org.uk ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users