I have an in-memory SQLite database which I want to serialize and send to another computer. Is this possible without writing the database out to disk and reading the file from there?
You could use the online backup API to transfer the in-memory database, to a file-based database created in shared memory (for Linux, in /dev/shm for instance) avoiding the disk operations. Then this pseudo-file is transferred to the remote host (still put in /dev/shm), and the online load API is used to transfer from the file-based database, to your target in-memory database.
See:
http://www.sqlite.org/backup.html
http://www.sqlite.org/c3ref/backup_finish.html
AFAIK, there is no API to perform online/load without intermediate databases.
The sqlite3 shell program contains a .dump command that "dumps the database in an SQL text format." You can use the source code for .dump (it is public domain) to create your own serializer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With