如何在Qt中的sqlite内存数据库和文件数据库之间备份/存储? [英] How to backup/store between sqlite memory database and file database in Qt?

查看:63
本文介绍了如何在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.

这篇关于如何在Qt中的sqlite内存数据库和文件数据库之间备份/存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆