简体   繁体   English

发送本地sqlite文件到服务器

[英]Send local sqlite file to server

I have a database of many users,which i want to store on both locally and on my server.Whenever user updates any information,i successfully updates it in local database using core database. 我有一个包含许多用户的数据库,我想同时存储在本地和服务器上。每当用户更新任何信息时,我都会使用核心数据库在本地数据库中成功更新它。 But how to change this information into the server?? 但是如何将这些信息更改为服务器? I am not getting this please help? 我没有得到这个,请帮忙吗? I thinking of sqlite file to server every time user updates his information. 每当用户更新信息时,我都会想到将sqlite文件存储到服务器。 but how to send data of sqlite file to server? 但是如何将sqlite文件的数据发送到服务器?

You have to use some tactics for this. 您必须为此使用一些策略。 Here is a short explanation of this work. 这是这项工作的简短说明。

1) Database Structure 1)数据库结构

2) Web service 2)网络服务

You have to design database at local and server side and manage flag(Bool) and update time. 您必须在本地和服务器端设计数据库,并管理标志(布尔)和更新时间。

1) Like when you launch app then you have to check your local data and take last update date and send request to server what's new update after this date. 1)就像您启动应用程序时一样,您必须检查本地数据并获取上次更新日期,并在此日期之后向服务器发送新的更新请求。 If there is any update then you can send data as a result of that webservice and handle that response at local device. 如果有任何更新,则可以通过该Web服务发送数据并在本地设备上处理该响应。

2) When you do some changes at local device then you have to manage flag, update time and created date. 2)当您在本地设备上进行一些更改时,则必须管理标记,更新时间和创建日期。 flag will show it has update on server or not. 标志将显示它是否在服务器上更新。 If updated then Y otherwise N. And you have to send created and updated date with this. 如果已更新,则为Y,否则为N。并且您必须与此一起发送创建和更新的日期。

During this request you have to manage in a same timezone. 在此请求期间,您必须在同一时区进行管理。 You can use standard UTC timezone because there may be chances that User can switch in different timezones so handle this. 您可以使用标准UTC时区,因为用户可能会切换到不同的时区,因此请进行处理。

If you need more clarification then you can ask at our chat room http://chat.stackoverflow.com/rooms/43424/coders-diary 如果您需要更多说明,则可以在我们的聊天室中询问http://chat.stackoverflow.com/rooms/43424/coders-diary

This approach definitely work for you. 这种方法绝对适合您。

Add a column to your local DB that is the last time updated. 在本地数据库中添加最近更新的列。 (I think there may be a way to get SQLite to fill this in semi-automatically for you, but even doing it "manually" is no big deal.) Then, when you want to upload updates, query for rows updated since the last upload. (我认为可能有一种方法可以让SQLite为您半自动填写,但即使“手动”完成也没什么大不了的。)然后,当您要上传更新时,查询自上次更新以来的行上传。 Ship to the server as JSON records. 作为JSON记录发送到服务器。

You can also keep a separate table that tracks updates, but that's for more complex scenarios. 您还可以保留一个单独的表来跟踪更新,但这是针对更复杂的场景的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM