问题描述
我有一个正常的预填充数据库.我想将它迁移到我的应用程序的核心数据.实现这一目标的最佳方法是什么.顺便说一句,我已经完成了这些事情,从苹果的示例中复制了 recipes.sqlite 数据库.导出了一个表 sql.根据核心数据表列重命名列名(类似这样 - 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:
- 您可以建立核心数据堆栈.
- 您会遍历非核心数据数据库中的每个表和每一行.
- 为每一行创建一个新的 Core Data 对象.
- 将旧行中的数据插入到新对象中.
这篇关于将普通 sqlite3 数据库迁移到核心数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!