简体   繁体   English

填充由CoreData创建的sqlite db

[英]Populating sqlite db created by CoreData

I have a sqlite DB created by my CoreData model automatically, but my app will not give the user the ability to write data into it, instead I wanted to pre-populate it with all the data the program needs. 我有一个由CoreData模型自动创建的sqlite数据库,但是我的应用程序无法使用户将数据写入其中,而是希望将程序所需的所有数据预先填充到数据库中。 My problem is that the sqlite DB created by CoreData has unknow tables and fields that where not present in my model. 我的问题是,CoreData创建的sqlite数据库具有未知表和字段,而这些表和字段在我的模型中不存在。 Is there anyway I can populate the DB created automatically with sqlite and only then use CoreData to read it? 无论如何,我可以用sqlite填充自动创建的数据库,然后才使用CoreData读取它吗?

The sqlite store created by Core Data should not be edited directly. 由Core Data创建的sqlite存储区不应直接进行编辑。 Use Core Data to populate it . 使用核心数据进行填充

How did you create the original sqlite db you're trying to use? 您是如何创建要使用的原始sqlite数据库的? If you created it with Core Data then you should be able to copy it into your app as long as the model is the same. 如果您是使用Core Data创建的,则只要模型相同,就应该可以将其复制到您的应用中。

You should prepopulate it using core data. 您应该使用核心数据对其进行预填充。 This might be useful www.pragprog.com 这可能对www.pragprog.com有用

The best way is to ship a prepopulated sqllite database. 最好的方法是运送预先填充的sqllite数据库。 If you have to update the database or want to perform the initial load, I can highly recommend this entry: http://cocoawithlove.com/2009/11/writing-parser-using-nsscanner-csv.html 如果您必须更新数据库或要执行初始加载,我强烈建议您输入以下内容: http : //cocoawithlove.com/2009/11/writing-parser-using-nsscanner-csv.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM