Lothar Märkle <[EMAIL PROTECTED]> writes: >>> Assuming you have a cgi-like application with many processes >>> that just looks up a row, displays and then exits. You can >>> simple use the rename call to atomically replace the db file >>> (see man 2 rename for bordercases) with another and without >>> locking. >>> >>> lothar >> >> but this will lose any update currently begin written by any >> of the active cgi processes - even if they are in the middle >> of a transaction? > > yes, this will only work with a read-only db, e.g. all your data > is pre-calculated once a day to a second db file, and then replace > the primary read-only db with it. > > But with read-only, one should avoid transactions at all. There > will be the risk of a -journal that doesn't correspond to the > db-file. I think this will break if rolled back? > > lothar
I need to copy a 'live' master database file and overwrite a read only file for pseudo replication. How do I ensure the database is flushed and acquire an exclusive lock on the master database? Will something like the code below do it? sqlite3_exec(db, "BEGIN EXCLUSIVE TRANSACTION", NULL, NULL, error); copyFiles(); sqlite3_exec(db, "COMMIT", NULL, NULL, error); Also are you sure it is completely safe to replace a read only database while reads are currently being done? Any help much appreciated. lars