Griggs, Donald wrote:
If your question still persists in the form of, "Is there a one-call method
in the API to write out any :memory: database to disk?", then I think the
answer is, "No, if ATTACH is too cumbersome, you would need to write your
own code as you see fit."
Henning,
Using a transaction to write directly to a file DB is your best bet, as
Donald has pointed out.
If you want to pursue the memory to file approach you will need to build
your own custom version of SQLite that incorporates the patch at
http://www.kordelle.de/sqlite/ which provides the
sqlite3_write_to_file() API (i.e it is not part of the standard SQLite
distribution). Then you will need to create your own version of the .NET
wrapper that adds functions to access this new API function. At that
point you should be able to save your memory DB to an associated file.
You can then query the file to retrieve your stored data.
I have to say the second approach seems like a *LOT* more work for no
real gain.
Once a file has been cached by the OS, direct file access is just as
fast as memory access using sqlite. The only tricky part is wrapping
bulk inserts with a transaction to eliminate redundant disk I/O. The
other trick is to read the file directly (i.e. using fread) to load the
file into the OS cache when you first open the database. This will speed
up your queries.
HTH
Dennis Cote