Synchronizing an SQLite client database with a MySQL server database

前端 未结 6 1724
遇见更好的自我
遇见更好的自我 2020-12-01 01:35

I have created an app in xcode with sqlite3.I want to create a button named sync to sync with my mysql database in my server. Any suggestion about sync process? Please let m

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 02:24

    A few questions:

    • Are you attempting a two-way sync, or just pulling updates from the server?
    • What update operations are acceptable? Insert/Update/Delete? In replicated databases, deletes are usually avoided.

    If you only need to pull inserts / updates from the server, you could create a PHP script, which would return the SQLite statements to execute. The php script would take a parameter of the last update sequence/time from the client.

    If you plan to do two way sync'ing, then you have to think about merges and conflict resolution. For two way, it's best for each side to have a transaction queue. Simply record every CRUD statement executed against the database. When syncing, apply these statements and then truncate the queue.

提交回复
热议问题