0

I am developing a app where i need to keep the replica of entire database from the web server to the IOS native sq-lite database, How can i keep updated version of db or import at loading of the app in one go, What should be my approach to go with this problem, Any help would be really appreciated,

Thanks Deepesh

Max
  • 3,753
  • 6
  • 33
  • 57
  • What type of database are you referring to? Mysql? – self Jun 24 '12 at 09:41
  • yes its mysql on the webserver and sqlite on the ios. – Max Jun 24 '12 at 10:11
  • 1
    i would parse the server response in json , and use core data for storage. – self Jun 24 '12 at 10:21
  • Generally you'd use JSON. The other option is to build the entire SQLite file on the server and sent the file in binary. – Hot Licks Jun 24 '12 at 11:45
  • (Note that there is no single common, freely available tool for "synchronizing" phone and server database info via incremental updates -- that you must concoct yourself.) – Hot Licks Jun 24 '12 at 11:47

1 Answers1

0

Looks like this is a popular problem. According to this answer,

Not every DB schema can be converted. MySQL is more complex and feature-rich than SQLite. However, if your schema is simple enough, you could dump it into an SQL file and try to import it / load it into an SQLite DB.

To do this, you can either use this mysql2sqlite.sh script like so

./mysql2sqlite.sh myDbase | sqlite3 database.sqlite

or use this answer and simply do

mysqldump database > database.sql
sqlite3 database < database.sql
Community
  • 1
  • 1
gregoltsov
  • 2,149
  • 1
  • 21
  • 36
  • Can i run this script in objective C, in the app (for example in view did load ) becuase i want an update from the ios native app. – Max Jun 26 '12 at 05:46
  • It is possible to run similar things in Objective-C. Look in [this thread](http://stackoverflow.com/questions/4656887/how-to-export-sqlite-file-into-csv-file-in-iphone-sdk) for more info on importing/exporting DB using [FMDB](https://github.com/ccgus/fmdb). – gregoltsov Jul 11 '12 at 12:37