Thanks for your reply. I know that I should lock the file before copying it,
and the "BEGIN IMMEDIATE" is indeed a nice trick.
However, I think I didn't explain my problem clearly. I would like to copy
that file _without_ using the sqlite library (so using the windows API
only).

When I try to do that with:
CreateFile(db_file,
               GENERIC_READ,
               0,
               NULL,
               OPEN_EXISTING,
               FILE_ATTRIBUTE_NORMAL, NULL);

I get error 0x20 - "the process cannot access the file becuase it is beging
used by other process".

I have two processes - one is linked with sqlite, and the other (which does
the copying) is not. I can lock using the first process, but I need to make
the copy with the other, and without linking to sqlite (although sqlite is
small, I find it a pity to link to it _only_ in order to do such a copy).

Thanks again,

Ran

On 6/21/06, Jay Sprenkle <[EMAIL PROTECTED]> wrote:

On 6/21/06, Ran <[EMAIL PROTECTED]> wrote:
> I have an application that uses sqlite3 API, and open the database file.
> While the file is opened (for reading) by sqlite3, I would like to copy
the
> database file (so to have a copy of the file). I guess I need to place a
> shared lock on the file (like sqlite3 does when reading from the file).
I
> wonder what is the recommended way of doing that.

Ran,
I do this to replicate the database for backup. Aquire an
immediate lock ( "begin immediate" ) then you can copy the
file. Source code in C++ is downloadable from my sqlite
support page (see the replicator).

--
SqliteImporter and SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite

Cthulhu Bucks!
http://www.cthulhubucks.com

Reply via email to