在iPhone应用程序的升级部署的SQLite数据库 [英] Deploying sqlite DB on iPhone app upgrade

查看:124
本文介绍了在iPhone应用程序的升级部署的SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的SQLite作为一个iPhone应用程序的数据源。我有一个关于应用程序的升级两个问题。

I'm using sqlite as a datasource in an iPhone app. I have two questions regarding application upgrades.

1)的数据是所有配置/非事务。这意味着,它是只读的。当我更新/添加配置数据,我会发出应用程序的升级。当用户获得一个更新的iPhone应用程序,对原件得到卸载?如果是这样的话,我是可以的,因为新的数据库配置数据将被部署。如果不是这样,我怎么替换数据?

1.) The data is all config/nontransactional. Meaning, it is readonly. When I update/add config data, I'll issue an upgrade for the app. When a user gets an updated iPhone app, does the original get uninstalled? If that is the case, I'm ok because the new db config data will be deployed. If that isn't the case, how do I replace data?

2)的数据是配置和交易。这意味着用户可以保存数据到分贝。当用户升级到应用程序的新版本,我想保持其现有数据,但替换所有配置数据。我猜我需要有存储应用程序内完成这项INSERT和UPDATE脚本。什么是有效的方式去了解它?

2.) The data is config and transactional. Meaning the user can save data into the db. When the user upgrades to a new version of the app, I want to maintain their existing data but replace all config data. I'm guessing I'd need to have INSERT and UPDATE scripts stored within the app to accomplish this. What is an efficient way to go about it?

推荐答案

cdespinosa已经描述的场景#1井,所以我会处理#2。

cdespinosa has described scenario #1 well, so I'll tackle #2.

我没有在iPhone上这样做还,但在桌面环境来处理这个最简单的方法是,让您的配置数据,在一个单独的数据库中。您可以连接到多个数据库比较容易。打开你的主数据库,这可能应该是可以更改数据库启动。然后 sqlite3_exec 附加语句,它看起来像这样:

I haven't done this on the iPhone yet, but on a desktop environment the easiest way to handle this is to keep your configuration data in a separate database. You can attach to multiple databases rather easily. Start by opening your main database, which should probably be the database that can change. Then sqlite3_exec an ATTACH statement, which looks like this:

ATTACH 'filepath' AS config;

从此,你可以做这样的事情:

From then on, you can do something like this:

SELECT * FROM UserTableName;
SELECT * FROM config.ConfigurationTableName;

这是我的理解是,如果你写的配置数据库的应用程序将失败签名检查,将不会启动,并列入SQLite的版本与iPhone够大了,不支持只读标志。出于这个原因,你应该配置数据库文件复制到沙箱并打开该副本,而不是一个在你的包。

It's my understanding that if you write to the configuration database the application will fail a signature check and won't start, and the version of SQLite included with the iPhone is old enough to not support the read only flag. For this reason, you should copy your configuration database file into the sandbox and open that copy instead of the one in your bundle.

(你可以,当然,使用SQL和从一个数据库复制到另一个值。但是,如果你已经复制整个配置数据库,以沙箱......,你应该......那么这只是一个额外的步骤,只是附上。)

(You can, of course, use SQL and copy the values from one database to another. But if you're already copying the entire configuration database to your sandbox... and you should be... then that's just an extra step. Just attach.)

我希望别人能为你提供更多的细节。 :)

I hope someone else can provide you with more details. :)

这篇关于在iPhone应用程序的升级部署的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆