18

Is there any way in which I can view my core data database without having to load it programatically through the code?!

5 Answers5

12

You should be able to view the database directly using the sqlite3 command line tool. The database should be stored in the following directory:

~/Library/Application Support/iPhone Simulator/User/Applications/{your application GUID}/Documents/{your application name}.sqlite

To view the database, just type in the following in a terminal (note, sqlite3 should already be installed on your system by default):

sqlite3 {your application name}.sqlite

You can then run regular SQL to view the data in the database.

Note, the following useful commands:

  • .help - Shows sqlite specific commands and what they do
  • .tables - Shows all tables in the database
  • .schema {followed by table name} - Shows the create statement used to create the table
  • .quit - Exits sqlite3
mmorris
  • 4,006
  • 3
  • 27
  • 29
jklp
  • 2,091
  • 2
  • 23
  • 37
  • 2
    The file name and extension does not have to be `{your application name}.sqlite` . It is whatever you save it as, for example: `user.data` . – mmorris Sep 05 '12 at 02:39
  • I am using firefox sqlite manager plugin; I am able to see table structures but no data in it. Although, if i make query from code, i am getting the records; I am also sure, its the exact path where i am searching. Any one facing this kind of problem? I am using XCode 6.3 – msmq May 12 '15 at 09:48
5

It depends what format the data store is (Core Data currently supports XML, binary, and SQLite persistent data stores). XML data stores can be viewed using a text editor. Binary data stores can only be accessed via code. You can open a SQLite data store via the sqlite command line or via any number of GUI SQLite browsers. Keep in mind, however, that the on-disk representation (in a data base or otherwise) is an implementation detail of how Core Data chooses to persist an object graph to disk. Don't rely on this format in any way except to satisfy your curiosity. If you are trying to track down a bug, there are much better ways than poking in the data store.

Barry Wark
  • 107,306
  • 24
  • 181
  • 206
4
~/Library/Application Support/iPhone Simulator/User/Applications/{APP GUID}/Documents/your_xcdatamodel.sqlite
joshwa
  • 1,660
  • 3
  • 17
  • 26
1

Follow these steps:

cd ~/Library/Application\ Support/iPhone\ Simulator
find . -type f -name "*.sqlite"

It's the one that is: [Project_Name].sqlite

I'm using Navicat Premium Essentials to view the database. In Finder, right click on:

Library Folder->Show View Options->Select Show Library Folder

This will enable you to navigate to open the file in any SQLite data browser (such as Navicat)

etayluz
  • 15,920
  • 23
  • 106
  • 151
0

you can go to Application Support folder (which is usually ~/Library/Application Support/YourAppname/) and view YourAppname.xml file.

Usually while in development CoreData storage is in XML format. You can change it in one of AppDelegate's methods (i presume you created Core-Data Application)

Eimantas
  • 48,927
  • 17
  • 132
  • 168