How can an in-memory SQLite database be saved to disk?

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
vfclists
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 30.10.2007, 00:07

How can an in-memory SQLite database be saved to disk?

Postby vfclists » 03.07.2016, 16:17

How can an in-memory SQLite database be saved to disk?

Is there support for it in Zeoslib, or does it have to be coded separately?

On checking StackOverflow I found this link http://www.sqlite.org/backup.html which uses the C-API. Does Zeoslib expose the necessary handles or variables which can allow the example there to be used?

marsupilami
Gold Boarder
Gold Boarder
Posts: 572
Joined: 17.01.2011, 14:17

Re: How can an in-memory SQLite database be saved to disk?

Postby marsupilami » 05.07.2016, 11:04

Hello vfclists,

this is not (yet) part of Zeos. But it should be fairly simple to implement. One would have to import sqlite3_backup_init() into the plain driver via modifying ZPlainSqLiteDriver.pas. After that you can implement something on top of this either as part of the dbc layer (ZDbcSqLite.pas) or as a separate object that only gets the session handle from the dbc layer.

If you want to implemet this, you can get the connection handle like this:

Code: Select all

(ZConnection1.DbcConnection as IZSQLiteConnection).GetConnectionHandle

And you can get the plain driver like this

Code: Select all

(ZConnection1.DbcConnection as IZSQLiteConnection).GetPlainDriver


Let me know if you need more information on implementing this. Since Zeos 7.2 is in Beta Stage I am not sure if these modifications can go in there or really should be part of the Zeos 7.3 branch that until now only has an OLEDB driver as its only difference to 7.2 until now.

If you decide to implemet this, and share your code here, your code could help to build a backup and recovery facility for Zeoi in the future. Firebird also supports doing backups via an API, that I want to implement at some time in the future...

With best regards,

Jan


Return to “ZeosLib 7.1 stable Forum”

Who is online

Users browsing this forum: No registered users and 1 guest