Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import an .sqlite3/.sqlite file to ios application?

I was having an excel file.

I have converted that file to .csv format and import that file to base and converted it into .sqlite file.

So the question is that:

Is there any way to import it into an ios app and manipulate the data.

Is there any way to use it like core data or import that file into core data.

Kindly refer any good tutorial preferably video tutorial or some other good one.

like image 554
Saad Chaudhry Avatar asked Oct 22 '13 19:10

Saad Chaudhry


1 Answers

You can use it directly with FMDB library: https://github.com/ccgus/fmdb Another option is to import that file into core data, but it is a little tricky. You can do it if you follow these steps:

  1. Create empty SQLite database in your application and run your app in simulator.
  2. Open simulator directory on your computer and locate SQLite database file.
  3. Look inside it with SQLite command line tool or something like "SQLite Data Browser" GUI tool (http://sqlitebrowser.sourceforge.net/).
  4. Import your data to this database file without changing structure and data in core data meta tables.
  5. Finally you have SQLite database file ready to be used with core data. So you put it into your app bundle.
  6. On first application launch you should copy your SQLite database file to appropriate directory (you know where you should put your file - you already found it in simulator app directory) before configuring core data stack.

It sounds a bit complicated but it works ;)

Nice article about shipping pre-populated data for core data: http://www.objc.io/issue-4/importing-large-data-sets-into-core-data.html

like image 162
opedge Avatar answered Nov 15 '22 00:11

opedge