How do I sync my data that has inserted value?


#1

The problem is… what if I inserted data on sqlite table then when I post it to the server it should be the primary key of sqlite and server must be disame when inserting… but the primary key genrated by the sqlite may not be disame when inserted to the mysql db…

How do I solve this problem ? only inserting of data made me confuse…


#2

If I understand your question correctly ,simply add another field to your table (not as primary key) (Main_Id) to store your your real primary key.


#3

I could do that… my problem is… I plan to add a Flag on the data which is its status … whether to be add, updated or deleted… interms of adding the data… I could insert it to the mysql DB and return the data to the device and then update the overall data on the sqlite db to make changes on the PRIMARY key … but what if the connection fail when processing the data… I could not trace which data is inserter by then… but the data was already added on the server…
Do you have any idea on how do I solve this ? :slightly_smiling:


#4

In these type scenario I use acknowledge system.

1- It must be transaction scope.
2- you update your server
3- you sent data to client
4- your client update it self
5- your client tell your server that it is updated

if one of this step get in trouble , transaction rolls back.