Thursday, 28 December 2017

Exploring Core Data database with sqlite3 on command line

Core Data abstracts a lot of the low level details of storage away for programmers, and that’s a good thing however sometimes it’s useful to lift the lid and see what’s happening beneath. For this post I’ll be specifically looking at the SQLite persistent store, I’ll assume you already have an app using Core Data and want to glean more insight into the inner workings. Fortunately the mac comes with a command utility to open and explore sqlite databases (sqlite3), but before we can delve into the database file, we must first find the file.

Finding the database file for an iOS App
The easiest way to look inside the database file is by running your app within the iOS Simulator for Xcode. The simulator stores all of its file structure within a directory on your mac. The trick is finding it. By default the simulator will store its files in Home Directory ▷ Library ▷ Developer ▷ CoreSimulator ▷ Devices. Normally the Library folder is hidden to prevent users mucking things up, however you can access Library from the Go menu in Finder by holding the option key down while displaying the menu.



However since we’re starting to perform some advanced techniques it may be easier to perform these actions on the command line, therefore open Terminal and type the following to perform a search of all the simulator devices for a file with a given name (you can substitute the file name for your own):
find ~/Library/Developer/CoreSimulator/Devices -name CoreDataDemo.sqlite

This will print a list of all the files found with the given name. However if you have been running your app on multiple simulators then multiple files will be displayed. It may not be obvious which file is for which simulator as the folders are named after the device identifier rather than a human readable name, additionally the files are not sorted therefore the first file may not be the most recent one.


To find out the Identifier for the simulated device, we can get it in Xcode by going to the Windows menu and selecting Devices and Simulators. This will open a new window, switch tabs to Simulators and select the simulator that your interested in. The Identifier will be displayed along with the summary information.


Since this can be rather painstaking, I've written as script that will search for a given database file and display the top 5 most recently modified files and the ability to directly open them. As well as listing a human understandable version of the simulator. The findcoredata.py script can be found on GitHub.


You’ll notice that the sqlite database file may not be alone. You may also have a file with ‘wal’ suffix, this is the Write-ahead log and a file with ‘shm’ for the Shared-Memory file. If you intend to copy the database then it is important that you copy these files also.

Look, but don’t touch
It is important to remember that you should avoid making modifications to the sqlite data file as Core Data will manage that. The sqlite3 command line tool can be used to execute commands against the database.


Perhaps I'll blog more on the internal structure of the database, but for now since you know how to find and open the database happy exploration.

82 comments:

  1. Dominant part of our mentors are graduated class of IIT, ISB and IIM and a couple of them are PhD experts. data science course in pune

    ReplyDelete
  2. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    machine learning courses in Bangalore

    ReplyDelete
  3. Such a very useful article. I have learn some new information.thanks for sharing.
    data scientist course in mumbai

    ReplyDelete
  4. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    Data science course in mumbai

    ReplyDelete
  5. I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!
    Data science course in mumbai

    ReplyDelete
  6. Such a very useful Blog. Very interesting to read this article. I have learn some new information.thanks for sharing. know more about

    ReplyDelete
  7. I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts. I curious more interest in some of them hope you will give more information on this topics in your next articles.
    Data Scientist course

    ReplyDelete
  8. Took me time to understand all of the comments, but I seriously enjoyed the write-up. It proved being really helpful to me and Im positive to all of the commenters right here! Its constantly nice when you can not only be informed, but also entertained! I am certain you had enjoyable writing this write-up.

    data science course
    360DigiTMG

    ReplyDelete

  9. The information provided on the site is informative. Looking forward more such blogs. Thanks for sharing .
    Artificial Inteligence course in Thiruvananthapuram
    AI Course in Thiruvanantapuram

    ReplyDelete

  10. This information is very impressive, I feel happy by reading your blog about Data Science and and I am interested learning more about this topic.
    Data Science Training In Hyderabad

    ReplyDelete
  11. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data science Interview Questions

    ReplyDelete
  12. Great post i must say and thanks for the information.


    Data Scientist Course

    ReplyDelete
  13. The context has been explained really well. Looking forward to see more of such informative updates
    Machine Learning Training in Hyderabad

    ReplyDelete
  14. Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
    Data Science Certification in Bangalore

    ReplyDelete
  15. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression

    ReplyDelete
  16. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

    Data Science Certification in Bangalore

    ReplyDelete
  17. Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject. buy 30 instagram likes uk

    ReplyDelete
  18. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression
    data science interview questions

    ReplyDelete

  19. This post is really helpful for us. I certainly love this website, keep on it.
    Data Science Course in Hyderabad

    ReplyDelete
  20. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing
    best data analyst courses in mumbai

    ReplyDelete
  21. This is my first time visit here. From the tons of comments ExcelR Machine Learning Course Pune on your articles.I guess I am not only one having all the enjoyment right here!

    ReplyDelete
  22. Amazing post found to be very impressive while going through this post. Thanks for sharing and keep posting such an informative content.

    360DigiTMG Data Analytics Course

    ReplyDelete
  23. I just wanted to thank you for the excellent reading!! I really enjoy every little bit of it that I have bookmarked for you to check out new stuff that you publish.https://360digitmg.com/course/certification-program-in-data-science

    ReplyDelete
  24. Great blog found to be well written in a simple manner that everyone will understand and gain the enough knowledge from your blog being more informative is an added advantage for the users who are going through it. Once again nice blog keep it up.

    360DigiTMG Python Course

    ReplyDelete
  25. I am really happy with your blog because your article is very unique and powerful for new reader.data science course in Hyderabad

    ReplyDelete
  26. Data Science Courses Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!

    ReplyDelete
  27. Data Scientist Courses Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! Cool stuff you have and you keep overhaul every one of us

    ReplyDelete
  28. I think this is the minimum value to earn more than just commit
    artificial intelligence course in noida

    ReplyDelete
  29. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. data science training in Hyderabad

    ReplyDelete
  30. Attend The Data Analyst Course From ExcelR. Practical Data Analyst Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analyst Course.
    Data Analyst Course

    ReplyDelete
  31. Attend The Artificial Intelligence course From ExcelR. Practical Artificial Intelligence course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Artificial Intelligence course.
    Artificial Intelligence Course

    ReplyDelete
  32. very well explained .I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Simple Linear Regression
    Correlation vs covariance
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  33. A Data Scientist starts his work by asking good questions and understanding the problem. data science course syllabus

    ReplyDelete
  34. Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.data science course in Hyderabad

    ReplyDelete
  35. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.data scientist course in pune

    ReplyDelete
  36. Attend The Business Analytics Courses From ExcelR. Practical Business Analytics Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Business Analytics Courses.
    Business Analytics Courses

    ReplyDelete
  37. hello sir,
    thanks for giving that type of information. I am really happy to visit your blog.Leading Solar company in Andhra Pradesh

    ReplyDelete
  38. wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated.

    Data Science Course in Pune

    ReplyDelete
  39. You totally coordinate our desire and the assortment of our data.
    data science course in noida

    ReplyDelete
  40. You totally coordinate our desire and the assortment of our data.
    data scientist course

    ReplyDelete
  41. Standard visits recorded here are the simplest strategy to value your vitality, which is the reason why I am heading off to the site regularly, looking for new, fascinating information. Many, bless your heart!
    data science courses in noida

    ReplyDelete
  42. Standard visits recorded here are the simplest strategy to value your vitality, which is the reason why I am heading off to the site regularly, looking for new, fascinating information. Many, bless your heart!
    best data science courses

    ReplyDelete
  43. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
    Data Science course in Hyderabad

    ReplyDelete
  44. Thankyou for this wondrous post, I am happy I watched this site on yippee. ExcelR Data Analytics Course

    ReplyDelete
  45. This post is very simple to read and appreciate without leaving any details out. Great work!
    data scientist course

    ReplyDelete
  46. Want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging endeavors.
    Business Analytics Course in Bangalore

    ReplyDelete
  47. I see some amazingly important and kept up to length of your strength searching for in your on the site
    data scientist certification

    ReplyDelete
  48. Thanks for the information about Blogspot very informative for everyone
    machine learning courses in aurangabad

    ReplyDelete
  49. Good Post! it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article, I want to say that also a well-written article with some very good information which is very useful for the readers.... thanks for sharing it and do share more posts like this.
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

    ReplyDelete
  50. Really well-written and informative blog. I liked it. I appreciate your effort in this blog. Keep sharing some more blogs again quickly. Thanks alot!
    Data Science Course in Hyderabad

    ReplyDelete
  51. Highly appreciable regarding the uniqueness of the content. This perhaps makes the readers feels excited to get stick to the subject. Certainly, the learners would thank the blogger to come up with the innovative content which keeps the readers to be up to date to stand by the competition. Once again nice blog keep it up and keep sharing the content as always.

    Data Science Course in Bhilai

    ReplyDelete
  52. I need to communicate my deference of your composing aptitude and capacity to make perusers read from the earliest starting point as far as possible. I might want to peruse more up to date presents and on share my musings with you.
    big data in malaysia

    ReplyDelete
  53. Thanks for Sharing this Valuable Information with us: this is very useful for me. Keep it Up.
    best data science course online

    ReplyDelete
  54. Nice and very informative blog, glad to learn something through you.
    machine learning course aurangabad

    ReplyDelete
  55. I was just examining through the web looking for certain information and ran over your blog.It shows how well you understand this subject. Bookmarked this page, will return for extra. data science course in vadodara

    ReplyDelete
  56. Thanks for the informative and helpful post, obviously in your blog everything is good..
    data scientist course

    ReplyDelete
  57. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Data Science Training in Bhilai

    ReplyDelete
  58. Your work is very good and I appreciate you and hopping for some more informative posts
    data scientist certification malaysia

    ReplyDelete
  59. Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.
    data science course fee in hyderabad

    ReplyDelete
  60. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one.
    cyber security certification malaysia

    ReplyDelete
  61. It is extremely nice to see the greatest details presented in an easy and understanding manner.
    data science course in hyderabad

    ReplyDelete
  62. Informative blog and knowledgeable content. Keep posting more blogs like this. Thank you.
    Data Scientist Course in Hyderabad

    ReplyDelete
  63. This is the first time I visit here. I found such a large number of engaging stuff in your blog, particularly its conversation. From the huge amounts of remarks on your articles, I surmise I am by all accounts not the only one having all the recreation here! Keep doing awesome. It has been important to compose something like this on my site and you have given me a thought.
    business analytics course in hyderabad

    ReplyDelete
  64. Nice Blog! such informative things you are sharing,I really liked your content. Get the best Data Science online course in the comfort of your home. Flexible timings, Best industry trainers, and meticulously crafted curriculum.business analytics course in chennai

    ReplyDelete
  65. There are also varieties of options available to choose a career in data science, like you can become a data scientist, developer, data engineer, analyst, database administrator, and many more.

    data science training in patna

    ReplyDelete
  66. wonderful article...keep up with your writing skills...Thanks for sharing...
    Data science training in Pune

    ReplyDelete
  67. Data Science Course in Nasik Best Training Institute Fees, Duration, Certification Online Classes Available There are no limitations to learning courses and one can indeed get multiple certificates provided he she completes the courses and clears the exam. PassedB.Sc. Degree from a honored University as defined by UGC, with at least 45 marks( 40 marks in case of candidates belonging to reserved order) and passed 10 2 examination with Mathematics as a subject. Curated by Hadoop experts, this Big Data Analytics course covers everything you need to gain proficiency in this field.data science course training in faridabad

    ReplyDelete
  68. "Your detailed guide to exploring Core Data's SQLite database using the sqlite3 command line tool is incredibly informative. Your step-by-step instructions, along with the script to find and open the database file, make it easy for readers to delve into the inner workings of Core Data. Your emphasis on not modifying the database file directly and your plans to potentially blog more about the database's internal structure show your commitment to thorough exploration. Thanks for sharing such valuable insights!"
    Data Analytics Courses In Bangalore

    ReplyDelete
  69. Hello,
    The article serves as a guide for developers who wish to gain deeper insights into the inner workings of Core Data's SQLite database through the use of command-line tools, while also emphasizing the importance of avoiding unauthorized modifications to the database. I enjoyed reading through this.
    Data Analytics Courses in Pune

    ReplyDelete
  70. This is a really useful post! Thank you for providing the procedures for investigating Core Data's SQLite database. It's ideal for developers who want to have a better knowledge of their app's data storage.
    Data Analytics Courses in Delhi

    ReplyDelete
  71. This post is quite helpful! I appreciate you sharing the steps to investigate the SQLite database of Core Data. It's perfect for developers who want to understand more about how your app stores data.
    Data Analytics Courses in Agra

    ReplyDelete
  72. Thanks for sharing the valuable content and its really useful and helpful for everyone.
    Data Analytics Courses In Chennai

    ReplyDelete