将本地 HTML5 DB(WebSQL 存储、SQLite)与服务器同步的最佳方式(2 路同步) [英] Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync)
问题描述
我正在开发一个带有本地数据库(使用 html5 webstorage)的移动网络应用程序(适用于 iPhone 和 Android),因此我的应用程序在用户离线时仍然可用.
I am developing a mobile web application (for iPhone & Android) with a local database (using html5 webstorage) so my app is still usable when the user is offline.
这运行良好,但我想将本地数据保存在服务器上.所以我需要将本地数据库与服务器上的数据库同步.同步只能是一种方式,但是以后我想两种方式都同步(服务器<->本地DB).
This is working perfectly, but I want to save the local data on a server. So I need to synchronize the local DB with a DB on a server. The synchronisation can only be one way, but in the future, I would like to synchronize it in the both way (server <-> local DB).
这个要求看起来很常见(或者在未来的移动网络应用程序中会很常见),但我找不到这样做的图书馆.
This requierement looks very common (or will be common in the future for mobile web app), but I can't find a library doing that.
我知道谷歌正在他们的移动网络应用程序(例如 gmail)中这样做,并且我发现了 WSPL 项目 一个谷歌项目,但没有下载源.
I know google is doing that in their mobile web app (ex. gmail), and I found the WSPL project a google project but without source to download.
如果我找不到解决方案,我会创建一个库来做到这一点,因为一种方式同步看起来并不困难,但我想知道是否还有其他解决方案.
If I can't find a solution, I will create a library to do that, as one way sync doesn't look difficult, but I wonder if there are other solutions.
推荐答案
- 我创建了一个名为 WebSqlSync 的小型 JS 库,用于将本地 WebSql 数据库与服务器(客户端 <-> 服务器)同步.非常易于使用和集成到您的代码中:
- I created a small JS lib named WebSqlSync to synchronize a local WebSql DB with a server (client <-> server). Very easy to use and to integrate in your code :
- 开源项目 QuickConnect 包含一个 JS 库,用于将本地 HTML5 SQLite 数据库同步到服务器数据库(MySQL 或其他):
- The open source project QuickConnect contains a JS library to synchronize the local HTML5 SQLite DB to a server DB (MySQL or other) :
- QuickConnect 的另一个项目是本机 SQLite 同步(iOS 或 Mac OS 的 Objective C 和 Android 的 Java):
- Another project from QuickConnect is a native SQLite synch (in Objective C for iOS or Mac OS and in Java for Android) :
- 我刚刚发现了另一个很有前途的 JS 库:persistenceJS
- 还有Impel.inTouch.它看起来很容易使用(包括php文件),但你必须在客户端使用Mootools框架:
- And there is also Impel.inTouch. It looks very easy to use (with php files included), but you must use the Mootools framework in the client side :
- Sencha 还有一个同步服务:Sencha.io.看起来不错,但它依赖于 Sencha Touch 框架:
- Sencha has also a synchronisation service: Sencha.io. Looks great, but it's dependent of the Sencha Touch framework:
https://github.com/orbitaloop/WebSqlSync
http://quickconnect.pbworks.com/Using-Enterprise-Synchronization
要使用此库,您需要使用框架的 DataAccessObject 来访问您的数据库.它的工作原理是存储应用于数据库的所有 SQL 请求(当然 select 除外),并将它们发送到服务器.管理删除很好,但是如果你更新很多,而且服务器需要使用相同的SQL语言,那就有点重了……
http://www.quickconnectfamily.org/qcdbsync/(我认为它还存储了所有 SQL 请求的历史记录)
http://www.quickconnectfamily.org/qcdbsync/ (I think it store also the history of all the SQL requests)
https://github.com/zefhemel/persistencejs
persistence.js 是一个异步 Javascript 对象关系映射器库.您可以在浏览器中使用它,也可以在服务器上使用它(并且您可以在它们之间共享数据模型)."
他们有一个数据库同步模块:persistence.synch.js 的文档
They have a DB synch module: DOC of persistence.synch.js
(在客户端使用 HTML5 DB SQLite 或 Google Gears,在服务器上使用 MySQL)
(works with HTML5 DB SQLite or Google Gears on the client, and MySQL on the server)
http://impel.simulacre.org/api/Impel.inTouch
http://www.sencha.com/products/io/
这篇关于将本地 HTML5 DB(WebSQL 存储、SQLite)与服务器同步的最佳方式(2 路同步)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!