SQLite Forum

Update Table Columns in SQLite in CoreData for iOS
Login

Update Table Columns in SQLite in CoreData for iOS

(1) By t_bard on 2020-04-24 19:19:14 [link] [source]

Hello,

I have no business trying to do anything in SQLite (Mac). I don’t even know if I should work through Terminal or XCode, but we are in a pandemic and the Developer for my iPhone app has not responded in over a month.

My problem is I need to completely update several columns in one of the “Tables” (entities?) in the CoreData.sqlite file of my iOS app. This is information that is permanent to each app version, downloaded once for that version, and is not impacted or interacted with by the user.

I might manage that outside of XCode, but I am wary of CoreData and can see that, even though the structure and field names of previous CoreData files is always the same, the metadata of past CoreData files is always different.

I know what I would so with my trusty Access 2000:

UPDATE Table_UPDATING, Table_2B_UPDATED SET Table_2B_UPDATED.[1] = [Table_UPDATING].[ONE], Table_2B_UPDATED.[2] = [Table_UPDATING].[TWO];

But, the XCode interface is daunting and I’m not even sure if it is best done through XCode.

Any good Samaritans who have a great idea?

Thanks

(2) By Simon Slavin (slavin) on 2020-04-25 01:09:26 in reply to 1 [link] [source]

Don't do this using direct access to the SQLite database. CoreData does caching and its own indexing of the values it stores, which can involve keeping more than one copy of data in the database.

If you want to update a CoreData database, do it using the CoreData API. Then you can be absolutely sure that your updates won't corrupt the database. And frankly it's no harder doing things that way than it is to learn SQLite if don't already know it.

(3) By t_bard on 2020-04-25 15:37:25 in reply to 2 [source]

Simon,

Thanks for your reply.

For the compleat idiot, I should use the CoreData interface in Xcode?

Do you have a Sample Command line for replacing a column (everything but the column head)? Is that too much of an XCode question for this Forum?

Thanks again,

(4) By Simon Slavin (slavin) on 2020-04-26 13:10:17 in reply to 3 [link] [source]

Sorry, but the thing you want is complicated and you can't do what you want to do without being a programmer. That type of programming is difficult and there is too much to learn to go from non-programmer to doing this with just the help of a few people on the web. I recommend you set this problem aside until you can pass the entire source code to an iOS programmer to work on it for you.