On Wed, Mar 01, 2006 at 07:38:58PM +0100, Elrond wrote:
> 
> Hi,
> 
> I'm considering to put the state of a running app into an
> sqlite db. I want it in a db, so external tools can query
> it and know, what the app is doing currently.
> 
> Any hints on how to clean up the db, when the app crashes?
> 
> (I have external resources, that I need to "lock", so the
> idea is to put the locks in the db, so more than one
> instance of the app can run and they don't kill the
> external resource.)
> 
> Any hints?

Depending on your needs, you might be able to just lock a row for
updates and hold that lock. IE, open a seperate connection to the
database and do:

BEGIN;
UPDATE process SET start_time = now() WHERE process_id = ?;

And then 'sit' on that connection until you're done. When you're
finished, just issue a COMMIT. Note that some databases won't like you
leaving that transaction open a real long time, so it depends on what
you're doing if this will work. I also don't know if SQLite cares about
such things.
-- 
Jim C. Nasby, Sr. Engineering Consultant      [EMAIL PROTECTED]
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Reply via email to