Validate core data sqlite file

  • Hi

    I am building an core data app that allows me to backup and restore the
    data.
    For backup, I simply copy the sqlite file to selected directory with a name
    'app.backup'.
    For restore, I also simply copy the selected file to the application
    storage directory with name 'app.sqlite'

    My question is: when I do restoring, How do I validate that the file is a
    valid sqlite database and its schema matches the core data data model I am
    using?

    Thanks,
    -
    Peng
  • On 12 May 2013, at 22:15, Peng Gu <panygu...> wrote:

    > Hi
    >
    > I am building an core data app that allows me to backup and restore the
    > data.
    > For backup, I simply copy the sqlite file to selected directory with a name
    > 'app.backup'.
    > For restore, I also simply copy the selected file to the application
    > storage directory with name 'app.sqlite'
    >
    > My question is: when I do restoring, How do I validate that the file is a
    > valid sqlite database and its schema matches the core data data model I am
    > using?

    Call -addPersistentStoreWithType:configuration:URL:options:error:
    It will fail if the store is of the wrong schema.
  • And here's the code to check sqlite db integrity …

    https://gist.github.com/robertvojta/1251278

    On Monday, 13. May 2013 at 11:10, Mike Abdullah wrote:

    >
    > On 12 May 2013, at 22:15, Peng Gu <panygu...> (mailto:<panygu...>)> wrote:
    >
    >> Hi
    >>
    >> I am building an core data app that allows me to backup and restore the
    >> data.
    >> For backup, I simply copy the sqlite file to selected directory with a name
    >> 'app.backup'.
    >> For restore, I also simply copy the selected file to the application
    >> storage directory with name 'app.sqlite'
    >>
    >> My question is: when I do restoring, How do I validate that the file is a
    >> valid sqlite database and its schema matches the core data data model I am
    >> using?
    >>
    >
    >
    > Call -addPersistentStoreWithType:configuration:URL:options:error:
    > It will fail if the store is of the wrong schema.
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today