如何在Qt中的sqlite内存数据库和文件数据库之间备份/存储?

问题描述:

Qt 中将sqlite 内存数据库备份/恢复到文件数据库的最简单方法是什么.

What's the easiest way to backup/restore sqlite memory database to file database in Qt.

我认为您需要直接使用 SQLite 来执行此操作.SQLite 有一个 Online Backup API,第一个例子是将内存数据库备份到文件数据库,所以应该可以做你需要做的事情.

I think you will need to work with SQLite directly to do this. SQLite has an Online Backup API, the first example is backing up an in-memory database to a file database, so it should be possible to do what you need to do.

要获取 sqlite3* 数据库句柄,请获取 驱动程序 (QSqlDatabase::driver) 从数据库中获取 句柄(QSqlDriver::handle).Qt 文档中的示例代码展示了如何将 QVariant 转换为 sqlite3* 句柄.

To get a sqlite3* database handle, get the driver (QSqlDatabase::driver) from the database then get the handle (QSqlDriver::handle). The example code in the Qt docs shows how to cast the QVariant into a sqlite3* handle.