>> Also, are there any code examples that demonstrate SQLite best >> practices, including how to correctly handle error conditions, such as >> the database is locked condition? I have been unable to find complete >> code examples. > > Can I point out that this is yet another person asking for the same > documentation ? I don't know enough about SQLite to write it, and I would > very much like to see someone do so.
I'd say there's no "best practices" here. Or let's say it another way: code experiencing "best practices" will be useless in the majority of use cases. And that kind of code is described in documentation and repeated on this list several times. I can repeat it once more: whenever you see "database locked" error rollback your transaction immediately and depending on your application start it from the beginning or return error message to the user. This will always work but it's not very convenient in many cases. SQLite is that kind of software that has pretty raw reaction on most events. And all processing of SQLite result codes depends on the application structure and its use cases. So SQLite user should be well aware of everything that's happening in his application or can happen outside (like command line tool) and implement appropriate reactions accordingly. For your particular case, Shawn, you can just do 3 things: 1. Ensure that you have no transactions started with SELECT and continued with INSERT/DELETE/UPDATE (if there are such then start them with BEGIN IMMEDIATE instead of BEGIN). 2. Set busy_timeout to some reasonable value (let's say 10 seconds). 3. When you work with the command line tool experience extreme carefulness and always keep in mind how your actions can impact your application: how long do you keep your transactions uncommitted or how long your SELECT statements are executed. All that times shouldn't be longer than busy_timeout you have set in the application. With all that you won't see "database locked" inside the application. Pavel On Fri, Jun 11, 2010 at 11:04 AM, Simon Slavin <slav...@bigfraud.org> wrote: > > On 11 Jun 2010, at 2:50pm, Odekirk, Shawn wrote: > >> Also, are there any code examples that demonstrate SQLite best >> practices, including how to correctly handle error conditions, such as >> the database is locked condition? I have been unable to find complete >> code examples. > > Can I point out that this is yet another person asking for the same > documentation ? I don't know enough about SQLite to write it, and I would > very much like to see someone do so. > > Simon. > _______________________________________________ > 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