根据版本将SQLite数据库更新为MySQL数据库

发布于 2024-12-24 19:22:23 字数 832 浏览 0 评论 0原文

我目前正在开发一个应用程序,该应用程序在应用程序商店中有一个很棒的工作版本,但现在是时候进行一些更新了。该应用程序的基本描述是它是一个信息应用程序。用户通过它来查找有关某些事物的信息。目前的情况基本上是静态的。所有信息都存储在 sqlite 数据库中,并从该数据库中提取以供用户查看。它根本没有什么特别的,只是位于我们都知道不可编辑的应用程序资源文件夹中。

我们需要更新的版本是完全动态的。我使用 MySQL 数据库构建了一个 Web 服务,其中包含更新信息的提要。这一切都很好。当应用程序启动时,它会删除 Documents 目录中的现有数据库,然后根据 Resources 目录中数据库的架构重新创建它。我可以在网络端执行更新,应用程序也会更新,这本身就是一项任务……哈哈,

这就是我的问题所在。我不想每次都经历这个过程,因为信息有点重,而且只会添加,但不会经常添加。因此,理想情况下,我希望数据库在第一次运行时更新,但直到数据库中的数据发生更改(也许每周左右)才再次更新。我想使用存储在我的网络服务端和应用程序端的数据库版本表来完成此操作。我建立了表格来保存版本,但我不知道如何比较两者。 IE MySQL数据库的版本为1,SQLite数据库也是1,所以没有任何反应。现在MySQL数据库的版本为2,而sqlite仍然是1,因此Documents目录中的sqlite数据库被删除,新的数据库被引入、解析并放入Documents目录中的sqlite数据库中。

解析和插入等所有工作都在 AppDelegate 中完成。我不太确定如何完成我想做的事情。我对此进行了大量的研究,并且确实发现了一些内容,表明这是与上次修改日期一起执行此操作的一种方法,但仅此而已。我真的很想坚持使用数据库版本方式,因为这就是我当前设置的方式。如果有人能为我指明正确的方向,我将不胜感激。如果需要更多详细信息,请询问...

I am currently working on an app which has a great working version on the app store, but now it’s time for some updates. A basic description of the app is that it is an informational app. Users get it to find out information about certain things. The one that’s currently up is basically static. All the information is stored in a sqlite database and is pulled from this database for the users to view. It’s nothing special at all, just sitting in the apps resource folder which we all know is not editable.

The version that we need to update it with is completely dynamic. I built a webservice with a MySQL database with feeds for the information that gets updated. This all works great. When the app starts it deletes the existing database in the Documents directory and then recreates it based on the schema of the database in the Resources directory. I can perform an update on the web side and the app updates as it should, which was a task in itself…lol

Here is where my problem lies. I don’t want to go through this process every time because the information is a bit heavy and only going to be added to, but not frequently. So ideally I would like the database to be updated on the first run, but not again until the data has changed in the database, maybe weekly or so. I would like to accomplish this using a database version table, stored on my webservice side and the app side. I have the tables built to hold the versions but I can’t figure out how to compare the two. I.E. The MySQL database has a version of 1, so does the SQLite database, so nothing happens. Now the MySQL database has a version of 2 and the sqlite is still 1, so the sqlite database in the Documents directory gets deleted and the new one gets brought in, parsed and put in to the sqlite database in the Documents directory.

All the work as far as the parsing and inserting is being done in the AppDelegate. I’m not too sure how to accomplish what I am trying to do. I have done an ample amount of research on this and I do find things that say that this is one way to do it along with last modified date, but that is about it. I would really like to stick with the database version way as that is what I am currently setup for. If someone can point me in the right direction for this I would greatly appreciate it. If any more details are needed please ask…

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文