Search code examples
iosmultithreadingsqlitecore-datafmdb

Use core-data and sqlite c based api simultaneously on same db


AFAIK CoreData can be configured to use sqlite in the persistent store.

so as core-data not provides way to query using SQL.

So core-data has sqlite db in background.

Is it safe to access same db using Core-Data and Sqlite c based api same time?

Will it lead to any data corruption is sqllite or any threading issues.

the reason why am I going to use any wrappers such as FMDB or C based API is to query complex data using sql query


Solution

  • It's probably safe but it's still a really bad idea. Core Data defines its own schema, which is undocumented and which is different from what you would use if you designed a SQL schema. So you'd have to create the Core Data model and then reverse-engineer your own schema to make direct SQL calls.

    Also, of course, it's going to be an absolute pain in the ass to keep changes in sync across completely different calling styles.

    This is a bad idea, even if it doesn't corrupt your data. You will regret using this approach.