数据库同步服务器到本地

发布于 2024-12-01 05:07:41 字数 422 浏览 0 评论 0原文

我有一个使用 SQLite 的本地应用程序。每当它可以访问互联网时,它就会从服务器请求整个数据库,并从中重新创建本地数据库。本地数据库和服务器数据库具有相同的结构,基本上本地数据库的目的是即使在没有互联网可用的情况下也能保证功能。

这是一种非常低效的方法。 我的问题是,如何仅询问丢失的数据?

我是否应该发送每个本地表中的最后一个 ID,并让服务器从该 ID 开始发送数据? 如果修改现有 ID 会发生什么?这意味着应该检查所有数据,但发送整个数据库进行检查并取回修改或添加内容似乎也很愚蠢。

配置是本地SQLite,服务器MySQL。如果建议的话我可能会将服务器更改为 SQLite。

编辑:
多个客户端向同一服务器MySQL数据库发出请求,PHP处理请求并回复。

你会如何解决这个问题?
谢谢。

I have a local app that uses SQLite. Whenever it has internet access it requests the whole database from the server and recreates the local one from that. Local and Server databases have the same structure, basically the point of the local one is to guarantee function even when no internet is available.

This is a very inefficient way of doing this.
My question is, how to ask for only data that is missing?

Should I send the last ID from each local table and have the server send data from that ID onward?
What happens if an existing ID was modified? This would mean that all data should be checked, but sending the whole database for checking and getting back the modifications or additions also seems stupid.

The configuration is Local SQLite, Server MySQL. I could probably change the server to SQLite if it's recommended.

EDIT:

Multiple clients make requests to the same server MySQL Database, PHP processes the request and replies.

How would you tackle this?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追风人 2024-12-08 05:07:41

我要么对数据库中的行添加时间戳并按日期获取,要么使用 rsync (或 librsync 或类似)来同步数据库文件。

I'd either timestamp the rows in the database and fetch by date, or use rsync (or librsync or similar) to synchronize the database files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文