Re: [sqlite] What's the safest, most elegant way to copy a live db.

2005-09-06 Thread Jay Sprenkle
> I suggest this approach: > > 1. Open the database file using sqlite3_open() > 2. Run sqlite3_exec("BEGIN IMMEDIATE"); > 3. Make a copy of the raw database file using whatever > high-speed file copy mechanism is at hand. > 4. sqlite3_close(); > > The BEGIN IMMEDIATE operation in step 2 will

Re: [sqlite] What's the safest, most elegant way to copy a live db.

2005-09-06 Thread D. Richard Hipp
On Tue, 2005-09-06 at 11:09 -0400, John Duprey wrote: > I'd like to copy a database that may or may not be in use. Doing a > filesystem copy will not ensure a stable copy. Can I use the sqlite3 CLI and > some SQL to do this such that I can wrap it up into a script or do I need to > write my own

Re: [sqlite] What's the safest, most elegant way to copy a live db.

2005-09-06 Thread Kervin L. Pierre
Hello, Seems to me if your backup program does a "BEGIN EXCLUSIVE" before doing the file copy then you should be fine. Just my guess though. I believe an exclusive transaction should ensure that you are the only writer to the database. Regards, Kervin John Duprey wrote: I'd like to copy a

Re: [sqlite] What's the safest, most elegant way to copy a live db.

2005-09-06 Thread Jay Sprenkle
On 9/6/05, John Duprey <[EMAIL PROTECTED]> wrote: > > What I'd like is a safe binary copy. > > From a previous post, I have seen someone suggest this: > attach 'foo.db' as bar; > create table baz as select * from bar.baz; > detach bar; > If I wrapped this in a loop for all tables it would

[sqlite] What's the safest, most elegant way to copy a live db.

2005-09-06 Thread John Duprey
I'd like to copy a database that may or may not be in use. Doing a filesystem copy will not ensure a stable copy. Can I use the sqlite3 CLI and some SQL to do this such that I can wrap it up into a script or do I need to write my own program, that gets a lock and re-creates the DB in a new