[英]Convert parts of mySQL DB from website into CoreData/SQLite on iOS
I have a website with mySQL database, parts of which I'd like to reuse in my iPhone app by populating CoreData DB (basically iPhone app is going to be an offline version of the website). 我有一个带有mySQL数据库的网站,我希望通过填充CoreData数据库在我的iPhone应用程序中重用其中一部分(基本上iPhone应用程序将成为该网站的离线版本)。
I am thinking of writing scripts which will translate mySQL into SQLite and then somehow feed the data into CoreData. 我正在考虑编写脚本,将mySQL转换为SQLite,然后以某种方式将数据提供给CoreData。
How would you accomplish this task? 你将如何完成这项任务?
Solution 解
Check out the following tutorial: 查看以下教程:
http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data
TL;DR - uses a python script to write to the SQLite database in a Core Data compatible format. TL; DR - 使用python脚本以Core Data兼容格式写入SQLite数据库。
Possible Drawbacks 可能的缺点
Alternative 替代
I'd dump the mySQL database to a CSV file, model the Core Data store in Xcode as unusual and write a quick and dirty importer within the application itself. 我将mySQL数据库转储到CSV文件,将Xcode中的Core Data存储模型设置为异常,并在应用程序本身内编写一个快速且脏的导入器。
You could use cCSVParse to do the CSV heavy lifting. 您可以使用cCSVParse来执行CSV重载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.