将正常的sqlite3数据库迁移到核心数据? [英] Migrate normal sqlite3 database to core data?

查看:119
本文介绍了将正常的sqlite3数据库迁移到核心数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常的预填充数据库。我想将其迁移到我的应用程序的核心数据。什么是实现这个的最好的方法。顺便说一下,我做了这些事情,从苹果的sample.exported表sql复制recipes.sqlite数据库。根据核心数据表列重命名列名称(类似于此 - id主键与Z_PK)。用我的值填充表。但我无法理解列名称Z_ENT和Z_OPT。有人知道如何轻松地将我预先填充的sqlite3数据库迁移到核心数据。

I have a normal pre-populated database. I want to migrate it to core data for my app. What is the best way to achieve this. By the way I have done these things, copied the recipes.sqlite database from apple's sample.exported a table sql. Rename the column names according to the core data table columns(something like this - id "primary key" with Z_PK). filled that table with my values. But i am unable to understand the columns names Z_ENT and Z_OPT. Does some one knows how do i migrate my prepopulated sqlite3 database to core data easily.

感谢

推荐答案

不要尝试手动创建核心数据SQLite文件。这是失败的道路;

Do not try and manually create a Core Data SQLite file. That is a road to failure; every time.

如果您有一个预先存在的SQLite文件,那么使用直接的SQLite工具来访问它并将其导入到Core Data using 核心数据。一旦你有一个核心数据堆栈中的数据,保存该文件,然后使用产生的SQLite文件。

If you have a pre-existing SQLite file then use straight SQLite tools to access it and import it into Core Data using Core Data. Once you have the data in a Core Data stack, save out that file and then use the resulting SQLite file.

Core Data SQLite文件的内部结构设计为不透明,不应进行逆向工程。苹果不保证文件结构保持不变。

The internal structure of the Core Data SQLite file is designed to be opaque and should not be reverse engineered. Apple makes no guarantee that the file structure will stay the same. They have changed it several times already since Core Data was released.

要进行导入,将像任何其他文件一样:

To do the import, it would be just like any other file:


  1. 你站起来核心数据栈。


  2. 为每一行创建一个新的Core Data对象。

  3. 插入数据从旧行到新对象。

  1. You stand up the core data stack.
  2. You walk through each table and each row in the non-Core Data database.
  3. Create a new Core Data object for each row.
  4. Insert the data from the old row into the new object.

这篇关于将正常的sqlite3数据库迁移到核心数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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