SQLite是否支持复制? [英] Does SQLite support replication?

查看:142
本文介绍了SQLite是否支持复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在嵌入SQLite3并使用内存数据库的应用程序中,是否可以在应用程序的两个运行实例之间复制数据库?我可以用自制程序协议来复制我所有的DB访问,但它似乎应该在DB层内完成。

In an application which embeds SQLite3 and uses an in-memory database, is it possible to replicate the database between two running instances of the application? I could do this by hand with a homebrew protocol duplicating all my DB accesses, but it seems like something that should be done inside the DB layer.

推荐答案

强力方法:发送.dump命令创建数据的文本表示。将数据读入第二个数据库。不确定你可以使用它。

Brute force approach: Send it the ".dump" command to create a text representation of the data. Read that data in into the second database. Not sure you can use that.

如果你需要一个细粒度的更新(发送一个副本到另一个副本),看看 sqlite3_update_hook

If you need a fine grained update (sending a copy of each upto the other copy), have a look at sqlite3_update_hook

但是你打算如何处理错误?例如,当app2中的数据库副本无法由于某种原因而无法进行更新时会发生什么?

But how do you plan to handle errors? For example, what happens when the copy of the DB in app2 can't make an update for some reason?

要解决此问题,请将数据库移动到服务器进程,有两个应用程序与它交谈。

To solve this, move the database to a server process and have the two apps talk to it.

这篇关于SQLite是否支持复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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