JAVA交钥匙SQL复制?
所以我的 Android 应用程序使用 SQLite 数据库。我需要使用中央服务器“复制”两个或多个表。远程服务器将合并来自远程客户端设备(我的应用程序)的数据,以及一些额外的字段,以使每个记录唯一,因为多个客户端设备将参与。
这肯定是使用 SQL 复制的开发人员的常见需求,因此我希望有人可以向我指出现有的(交钥匙)解决方案。
如果没有,我想考虑不需要我编写有关表模式的大量细节的方法。也许我可以只指定表并指定服务器,仅此而已。我想我什至可以将 sqlite 转储到文件然后传递文件?
想法?
谢谢!
So my Android app uses a SQLite database. I need to "replicate" two or more tables with a central server. The remote server will merge the data from remote client devices (my app), along with a few extra fields to make each record unique, since multiple client devices will be participating.
This must be a common need for developers using SQL replication so I'm hoping someone can point me to an existing (turn-key) solution.
If not, I would like to consider methods that doesn't require me to code a lot of specifics about the table schema. Perhaps I could just specify the table and specify the server and that's it. I guess I could even sqlite dump to file then pass the file?
Thoughts?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要向中央服务器发送数据(如您所说的复制),还是还需要从该服务器接收数据(同步)?如果您只需要发送数据并且带宽/数据使用不是限制,那么您可以使用您需要的数据创建 CSV 或 TSV 文件,可选择将其压缩并将其发送到服务器,并在服务器中实现所有合并逻辑。即使它不是特定于表的,您也需要确定如果您已经拥有相同或非常相似的数据(覆盖、忽略、错误?),该怎么办。
我建议不要只发送原始 SQLite 数据,因为这会在服务器上创建与 SQLite 不必要的依赖关系。创建 TSV 文件并不难。
我认为没有任何交钥匙解决方案可以满足您的需求,尽管有许多库和框架可以帮助您在服务器端实现它。
Do you only need to send data to the central server (replication as you say), or do you also need to receive data from that server (synchronization)? If you only need to send data and bandwidth/data usage is not a constraint, then you can create a CSV or TSV file with the data you need, optionally compress it and send it to the server, and implement all merging logic in the server. Even if it's not table-specific, you need to determine what to do in case you already have identical or very similar data (overwrite, ignore, error?).
I would advise against just sending raw sqlite data, since that would create an unnecessary dependency with sqlite on the server. Creating a TSV file isn't hard.
I don't think there are any turn-key solutions for what you need, though there are many libraries and frameworks to help you implement it server-side.