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

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

问题描述

我有一个普通的预填充数据库.我想将它迁移到我的应用程序的核心数据.实现这一目标的最佳方法是什么.顺便说一下,我做了这些事情,从apple的sample.exported一个表sql中复制了recipes.sqlite数据库.根据核心数据表列重命名列名(类似这样 - id "primary key" with 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.

谢谢

推荐答案

不要尝试手动创建 Core Data SQLite 文件.那是一条失败之路;每次.

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

如果您有一个预先存在的 SQLite 文件,那么使用直接的 SQLite 工具来访问它并将其导入到 Core Data 使用 Core Data.将数据放入 Core Data 堆栈后,保存该文件,然后使用生成的 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 文件的内部结构被设计为不透明的,不应进行逆向工程.Apple 不保证文件结构将保持不变.自 Core Data 发布以来,他们已经对其进行了多次更改.

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. 您浏览非核心数据数据库中的每个表和每一行.
  3. 为每一行创建一个新的 Core Data 对象.
  4. 将旧行中的数据插入到新对象中.

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

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