0

How can I export data from an sqlite3 database in Objective-c? Can I issue a dump command at least? What options do I have for exporting?

luvieere
  • 37,065
  • 18
  • 127
  • 179
  • This question is similar to yours: http://stackoverflow.com/questions/1512883/how-to-convert-data-to-csv-or-html-format – Brad Larson Oct 05 '09 at 12:19
  • Umh... I am trying to avoid having to "reinvent the wheel" here by writing the thing at the lowest level... I was wondering if there might be some already known and tested way to do the export, something in the sense of the FMDB wrapper. – luvieere Oct 05 '09 at 12:40
  • No. There's not any way without using some 3rd-party library. – Ed Marty Oct 06 '09 at 04:04

2 Answers2

1

I'm not aware of any built-in method for dumping a SQLite database in the sqlite api. However, I imagine you could probably cook something up to find all tables and their schemas, then SELECT * FROM each one and export it as a text file manually.

Ed Marty
  • 39,590
  • 19
  • 103
  • 156
1

You can look into how the .dump command is implemented by the sqlite shell, to see how you can accomplish the same thing. In particular take a look at the dump_callback function and also the actions taken when the word dump is seen by the shell

Shell.c source code: dump_callback()

Brandon Bodnar
  • 8,202
  • 2
  • 36
  • 42