I am using Zeoslib to create in-memory databases with SQLite, and I need to the save the database onto disk when the program closes or dump it to a file regularly.
As the SQLite3 program cannot handle in memory databases, is there a way to get SQLite to export the output of a SELECT query as INSERT statements?
PS. sqlite3 can dump an in memory database to disk as indicated in this thread, but the in-memory database is created by a different application, which is why I can't see how to get the example to work.
To save a memory DB to disk, create a copy with SQLite's backup API. This requires that your database driver actually supports the backup API; Zeos apparently does not.
What makes a database on disk so slow are not the disk accesses themselves (most could be cached), but the synchronizations to ensure that the DB stays intact even if the program or the computer crash.
There are a number of settings that increase speed, at the cost of making an on-disk DB as unsafe as an in-memory DB:
Set PRAGMA synchronous to
OFF:Set PRAGMA journal_mode to MEMORY:
Increase PRAGMA cache_size (the default is typically only 2 MB);
Disable PRAGMA secure_delete.