HI everybody, i have a question。
A sqlite have about 15 tables,and mysql same.i want sqlite to sync mysql every ho开发者_如何学JAVAur,what can i do?
i have a idea ,use a (script / php) to export sqlite'tables value and (send to mysql or sent url),and mysql use a (script / php) to update DB.but this way like not good.
or have some tool that i can use?
thanks all.
If you don't want to do full exports/imports each time, what you would have to do have a "last_modified" field in each table that contains a date for when that row was last modified. Then on each sync, save the current timestamp, and on the subsequent sync, issue a query like:
SELECT * FROM TABLE WHERE last_modified > $last_sync_timestamp
..and you get your list of updated rows.
Note that this won't "propagate" rows that get deleted from the tables. Instead of deleting those rows, what you'll need to do is have another field called "visibility" that is toggled to false when a record is deleted, and your application modified so that said rows are not shown. Then have your syncing code actually delete the "not visible" rows from the table after a certain number of syncs.
Hope this helps.
精彩评论