Convert parts of mySQL database from website to CoreData / SQLite on iOS

I have a site with a mySQL database, parts of which I would like to reuse in my iPhone application by populating the CoreData database (basically the iPhone application will be a standalone version of the website).

I am thinking of writing scripts that will translate mySQL into SQLite, and then somehow load the data into CoreData.

How would you complete this task?

+6
source share
1 answer

Decision

Check out the following tutorial:

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 format compatible with Core Data.

Possible disadvantages

  • If you have a complex database, this can become messy.
  • If there are errors in the SQLite database format, Core Data is not tolerant, and you may receive unexplained failures.
  • Apple recommends that you never contact the data warehouse directly, which makes me a little nervous about this approach.

Alternative

I would dump the mySQL database into a CSV file, simulate the master data repository in Xcode as unusual, and write a quick and dirty importer in the application itself.

You can use cCSVParse for heavy lift CSV.

+3
source

Source: https://habr.com/ru/post/902312/


All Articles