如何将一个预先存在的sqlite文件导入Core Data? [英] How to import a pre-existing sqlite file into Core Data?

查看:124
本文介绍了如何将一个预先存在的sqlite文件导入Core Data?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个.sqlite文件导入Core Data,我在互联网上搜索,发现:

I need to import a .sqlite file into Core Data, I searched on the internet and found:

Core Data教程:如何预加载/导入现有数据

正在创建一个Python脚本,通过读取旧数据库的内容并在新数据库中创建相应的行来填充此数据库。但是我的sqlite数据库在表和列数方面太大了,这可能花费我大量的时间。

It is creating a Python script to populate this database by reading in the contents of our old database, and creating the appropriate rows in the new database. But my sqlite database is too large in term of number of tables and columns, this may cost me a considerable amount of time.

我也发现这个:

在iPhone OS 3.0上使用预填充的SQLite数据库与核心数据

但我不相当理解它,它看起来像是将旧数据库复制到一个新的,然后如何添加Z_后缀到所有的表和列名称?此外,它要求我创建实体和属性,是否还可以自动完成(从sqlite dabase文件)?

But I don't quite understand it, it looks like it's copying old database to a new one, then how does it add Z_ suffix to all the table and column names? Also, it asks me to create entities and attributes, is there anyway this can be done automatically(from sqlite dabase file)?

谢谢!

推荐答案

这里的答案可能有用(我是其中之一)

This answers here might be useful (mine is one of them)

预填充核心数据

 /**
 Returns the path to the application's Documents directory.
*/
      - (NSString *)applicationDocumentsDirectory {
          return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  NSUserDomainMask, YES) lastObject];
      }

示例代码

这篇关于如何将一个预先存在的sqlite文件导入Core Data?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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