Re: Import sqlite data file
Re: Import sqlite data file
- Subject: Re: Import sqlite data file
- From: Chris Hanson <email@hidden>
- Date: Mon, 16 Apr 2007 13:34:55 -0700
On Apr 16, 2007, at 11:50 AM, Lorenzo Quadri wrote:
Hi, I'm new in Cocoa and I need to know if is possible import file
from
a SQLite database in core data file and how to do it.
It's very straightforward.
Use the SQLite API to get the data you want to import from your SQLite
database, and you use the Core Data API to create a Core Data object
graph representing the imported data and save it in a Core Data
persistent store.
There's no "automatic" import of any sort -- not "even" to generate a
Core Data managed object model for a given XML or SQLite database
schema -- because that would require accurately inferring the intent
of the schema from only the schema.
A relational database schema doesn't always always exactly specify its
intent. Often that's left up to business logic outside the database
itself, or to stored procedures. (Both of which are Turing-complete
and therefore impossible to analyze 100% accurately in all cases.)
This is especially the case with constraints; often the real
constraints on the data in a database are much more "interesting" than
what is specified in its schema.
For one example, SQLite doesn't actually enforce foreign key
constraints. Therefore, many users of SQLite don't even bother
specifying them (since they may wind up being inaccurate due to bugs
etc.). Therefore, you can't take an arbitrary SQLite schema and
generate a correct E-R model from it. You can *guess* but since
you're guessing, it's possible to guess wrong.
Rather than try to do all of this, Core Data lets the developer -- who
is assumed to know what they're doing, and what their actual needs are
-- handle it.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden