What's the easiest way to view the contents of an SQL file / app data from an iPhone backup? - iphone

I'm looking for an easy way to make sense of a SQL file that I've pulled from some application data in an iPhone backup. It's a huge file with bits and pieces of readable data strewn throughout, and right now I'm reduced to using a text editor to pick through it, which will take years.
Are there any simple SQL viewers available that would work for someone with limited technical knowledge? Or is there a way to export the contents of the file to a more easily readable format?
Really appreciate any help!

Try Base, it is a paid app, but they have a free trial if you download outside of the Mac App Store. I use is daily for sqlite db's

I use SQLiteManager.
There are several other sqlite viewers, like Navicat, but I haven't used them personally.
Alternatively, you can just use sqlite on the command line:
sqlite3 path-to-file
.dump
.quit

Related

core data : phpmyadmin equivalent

In my app, I have a pretty huge datamodel and its .sqlite data file.
I would like to parse my records in the .sqlite file, and I'm wondering if there was a tool, like phpMyAdmin.
It would be an xCode tool, for example, or maybe a custom app downloadable on the web.
Does anyone know that kind of tool ?
There are any number of SQLite readers available, but SQLite Manager is popular:
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
i like the Core Data Editor, but it is quite expensive (23,99€)
Website:
http://christian-kienle.de/CoreDataEditor
Mac App Store:
http://itunes.apple.com/de/app/core-data-editor/id403025957?mt=12
the cool thing is, that core data editor is even able to generate (good and readable) code

Extract a table from call_history.db using C++ and sqlite

I'm developing an iphone app that retrieves the call log information and store it with the number of missed,incoming and received calls over that time. Here, since the call log is a .db file, i have to first access the call log details and extract it using C++ and sqlite.
Can anyone suggest me how to extract the table named "call" from call_history.db database file and store it in a text file?
I don't think that is allowed by Apple to access the call history database... If it is, which I seriously doubt, then you should be able to open it using sqlite3. There are plenty of tutorials available online how to do this but again, I think, if it is even possible, that your app will be rejected for this...
If you still want to try, the call_history.db file is probably a sqlite3 database.
Have a look at the documentation to see how to access it from your code. If you want to analyze the contents first to find out the schema, just use the command line application sqlite3.

How to programmatically fill a database

I currently have an iPhone app that reads data from an external XML file at start-up, and then writes this data to the database (it only reads/writes data that the user's app has not seen before, though)
My concern is that there is going to be a back catalogue of data of several years, and that the first time the user runs the app it will have to read this in and be atrociously slow.
Our proposed solution is to include this data "pre-built" into the applications database, so that it doesn't have to load in the archival data on first-load - that is already in the app when they purchase it.
My question is whether there is a way to automatically populate this data with data from, say, an XML file or something. The database is in SQLite. I would populate it by hand, but obviously this will take a very long time, so I was just wondering if anybody had a more...programmatic solution...
I'm going to flesh out Jason's answer, I've marked my post as a community wiki so I shouldn't get any points for this.
He's not talking about a dummy app - write the app as you normally would, but check to see if the database exists in your main bundle before you call the code that populates the plist. You run that in the simulator, pull out the generated sqllite database, and add it to your project - if you only need to read from it, you can read it from the main bundle directory. If you need to do further writes then copy it into the writable documents area, and use it from there. So basically for the main user, the code to populate the DB would never be called...
The only downside is you also end up including the plist files you are reading from, even though you only need the database. You could make a different build target that was a copy of the main one with the only difference being that it held the plist files, while the main target you built for the app store did not.
Not to take Jason's answering thunder, I can't comment yet so it has to be here.
The nice thing is that you can access the filesystem of the simulator right on your Mac. I am away from mine at the moment or I could tell you exactly where to look, but I just find it by putting the name of the db file into searchlight and just running with that.
You also do not need to wright any code to populate the db since you can use the command line tool to do the initial setup if that is more convenient.
You will need to copy it over though since resources are stored in the read only signed portion of the app bundle.
I had the same problem of you using sqlite, on massive insert it's really slow. So the best way it's provide directly a filled sqlite database.
You have another way, instead of INSERT INTO, to populate a sqlite db. You can produce a csv file for each table and load into the tables using your computer and the sqlite shell:
Just 2 simple commands:
.separator SEPARATOR
.import FILE TABLE
Example:
adslol:~ user$ sqlite3
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .separator ;
sqlite> .import myData.csv nameOfMyTable
sqlite> .quit
I hope it's what you was looking for :)
If you need a good client for sqlite3 try SQLite Manager, it's a Firefox add-ons.

free sqlite tools

looking for a free sqlite tool, any suggestions? I need a export, import functionality.
Thanks for the recommendation.
I love SQLite manager: https://addons.mozilla.org/en-US/firefox/addon/5817
Oddly enough, it's a firefox addon.
MS Excel or Access can be used to browse SQLite data, too
I spent all day looking for a Windows tool to browse/explore contents of SQLite and tested many of the ones listed on http://www.sqlite.org/cvstrac/wiki?p=ManagementTools . Some I like and will explore further but many I find lacking for they either require install of other frameworks (.Net XXX), are too big, slow browse of big tables, weird interface, (mis)handling of BLOBs, lack of import/export facilities.
I have no issue using SQL from command line but in many occasions i find it useful to examine the data in file browser/spreadsheet fashion (as in MS Excel or Access).
Here is another alternative: if you have either Access or Excel installed on your machine, get ODBC driver and connect to the SQLite DB that way. While MS Office ain't free, for many people it is already installed on the PC.
Important note when connecting from Access: i was getting "Reserved error -7778" when trying to link the SQLite tables in, so i was assuming SQLite ODBC just won't work with MSAccess. Not so, i found after a bit of digging. All one has to do is avoid using File Data Source (File / Get External Data / Link tables... / ODBC - and then instead the "File DS" tab, go to the "Machine DS").
I've used http://sqlitebrowser.sourceforge.net/ when I need to quickly browse/edit an sqlite database. There's a very long list of other such tools at http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
SQLMaestro (http://www.sqlmaestro.com/products/sqlite/datawizard/) has a good range of bulk import/export with what looks like over 20 formats (but since I don't need bulk import/export, I haven't tried this program). Oops ... look like i missed the "FREE" part
I'm using the FREE Firefox plugin SQLite Manager (https://addons.mozilla.org/en-US/firefox/addon/5817) and it is really handy. It will handle a few import/export formats (CSV, SQL and XML)
SQLiteMan (http://www.sqliteman.com/) can import in half a dozen or so formats. Export doesn't seem obvious. Its free as well.
A few more FREE options (none of which I have tried include)
SQLite Administrator(http://sqliteadmin.orbmu2k.de/)
SQLiteStudio (http://sqlitestudio.one.pl/index.rvt)
I've used the Arca Database Browser with good results, available here: http://xtras.tabuleiro.com/download/arca.htm.
SQLite Maestro sounds like it meets your needs.
Probably
SQLiteMan
is about the best and most well known.
I personally like:
SQLite Administrator
as it's very small and lightweight, but does have it's quirks. However, there's a whole list of SQLite tools (both free, open source and commercial) here:
Commercial and freeware Sqlite tools list
Now i use Lita - SQLite Administration Tool
it's a free applications developed in Adobe Air.
the only thing that disturbs me is that it sorts the columns when you query.
Besides that it does what I want.

Is there a way to access AddressBook db file programmatically?

i need to copy this database file and save it in someother location or i can take backup of the db file. is there a way to do this programmatically.
Thanks
Satish
Unless you've jailbroken your iPhone, there's no way of accessing the sqlite3 database directly on the phone.
If you're talking about getting access to the database from your computer, you can do it by grabbing the database files out of the iPhone backup files. To do that, you'll need to grab a copy of Erica Sadun's mdhelper (binary file) command line utility, and run it from the PC you sync your laptop with like so:
mdhelper -files "AddressBook.sqlitedb" -extract -glob
This will create a "~/Desktop/Recovered iPhone Files" directory containing a file called AddressBook.sqlitedb, which you can access directly or query using your programming language of choice.
If you don't trust downloading and running binary files without knowing what they do, you can look at the source on Github and compile it yourself.
the SQL database can be extracted from an iphone backup. I used this software to grab mine and the SMS database.
If you have lots of images/videos in camera roll it can take a while to run.
http://www.supercrazyawesome.com/
Yeah sorry abt that. ok thanks probably i will create a new database using AddressBook Apis
-Satish
You can also take a backup of your iphone and than use one of tools discribed here to identify the file you need.