Gaspard Bucher
------------ founder, coder teti sàrl (http://teti.ch) On Wednesday, 3 April 2013 at 23:11, Tiago Rodrigues wrote: > Hello all, > > I'm writing a small simulation app and for it I would like to use SQLite3 > as an application file format, as suggested by the "Appropriate uses for > SQLite" page in sqlite.org (http://sqlite.org). More specifically, the page > suggests calling > BEGIN TRANSACTION when opening a file and calling COMMIT when saving it > again, or ROLLBACK if closing it without saving. Simple enough, up until > the point where I want to implement a "Save As..." menu option, where the > current state of the application is saved to a new file (new database) with > the changes, while the changes in the current file are rolled back. > > For that, the simplest idea would be to use the online backup family of > functions, calling sqlite3_backup_init() and sqlite3_backup_step() on the > database, calling COMMIT on the backup and ROLLBACK on the original. > Naturally, that doesn't work, as you can't back up a database in the middle > of a transaction -- sqlite3_backup_step() returns SQLITE_BUSY. > > That being said, has anyone on the list encountered (and hopefully solved) > this particular problem? This probably means I have to scrap the idea of > holding a transaction through the editing of the file, but then should I > copy the database to a memory-based db? Any particular tips or caveats? > > I appreciate the attention, > > -Tiago > > -- > In those days, in those distant days, in those nights, in those remote > nights, in those years, in those distant years... > - Gilgamesh, Enkidu and the Underworld > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org (mailto:sqlite-users@sqlite.org) > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > Just in case, I implemented save/restore functions in the lua bindings to sqlite3. This example should be easy to adapt to save/restore using std::string. https://github.com/lubyk/sqlite3/blob/master/vendor/LuaSQLite/lsqlite3.c#L829 Gaspard _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users