For the impatient :
- connect to your iphone (ssh) and transfer AddressBook.sqlitedb from your home dir;- do locally sqlite3 AddressBook.sqlitedb;
- type:
.output address.csv
.mode csv
select
p.First , p.Last , p.Organization,p.displayname,
CASE WHEN v.label > 5 THEN 'mail' ELSE 'phone' END,
v.value
from ABMultiValue as v, ABPerson as p
where p.ROWID=v.record_id;
And that's done
I am pretty sure there are apps to backup your contact from your phones.
However, my iphone I discovered lately was illegal and dangerous: it was jailbreaked.
In order to strictly follow the law, and not because it does not work anymore in a scary fashion that make me think it is dying, I bought an android to replace it.
One thing occured to me. Had I no warning, I would have been dead without my contact I carelessly forgot to backup. So I decided to opt for a long lasting technology: paper printed notebook.
So first, I used my ssh server on my iPhone to connect (no my pass is not alpine). I found there was a very nice AddressBook.sqlitedb in my home dir, and copied it on linux.
I wanted to make a demo of sqlsoup, but on linux mint sqlsoup support for sqlite is broken.
Anyway I needed to learn sqlite in less than 2 hours. Because, sqlite cannot be as infuriating as "NoStandardEspciallyNotSqlBecauseReinventingTheWheelPoorlyIsSoCool"
I did a simple introspection (.schema)
sqlite> .schema
...
CREATE TABLE ABMultiValue (UID INTEGER PRIMARY KEY, record_id INTEGER, property INTEGER, identifier INTEGER, label INTEGER, value TEXT);
CREATE TABLE ABMultiValueEntry (parent_id INTEGER, key INTEGER, value TEXT, UNIQUE(parent_id, key));
CREATE TABLE ABMultiValueEntryKey (value TEXT, UNIQUE(value));
CREATE TABLE ABMultiValueLabel (value TEXT, UNIQUE(value));
CREATE TABLE ABPerson (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, First TEXT, Last TEXT, Middle TEXT, FirstPhonetic TEXT, MiddlePhonetic TEXT, LastPhonetic TEXT, Organization TEXT, Department TEXT, Note TEXT, Kind INTEGER, Birthday TEXT, JobTitle TEXT, Nickname TEXT, Prefix TEXT, Suffix TEXT, FirstSort TEXT, LastSort TEXT, CreationDate INTEGER, ModificationDate INTEGER, CompositeNameFallback TEXT, ExternalIdentifier TEXT, StoreID INTEGER, DisplayName TEXT, ExternalRepresentation BLOB, FirstSortSection TEXT, LastSortSection TEXT, FirstSortLanguageIndex INTEGER DEFAULT 2147483647, LastSortLanguageIndex INTEGER DEFAULT 2147483647);
CREATE TABLE ABPersonChanges (record INTEGER, type INTEGER, Image INTEGER, ExternalIdentifier TEXT, StoreID INTEGER);
...
My arch nemesis is there an EAV (Entity Attribute Value) soft model: ABPerson are the persons you know, and ABMultiValue is where your values are, and the game is to found what reference them and the name of the attribute.
Normally getting EAV values is a 2 joints :
- you get the value attached to the person and display the category of the value.
Well, screw that: a fast scan on ABMultiValueLabel tells me phone id is less or equal to 5.
Then a quick trial error tells you the record_id referenced in the EAValue table is the person ROWID.
What we learnt?
SQL is cool: even if sqlite is not mysql/sqlserver/postgresql the learning curve is close to zero. No surprise, so I am happy with SQL.
Apple uses an MVC for the contact App.
- the model are the DB table;
- the controller are the triggers in the DB;
- the view is the objective C code.
KISS, nice, efficient.
I don't like EAV, but it is an easy way to attach n "things" to a contact. Thanks to this you can have 6, 9 or 666 mails/phone for a person.
I am still pissed off at apple and google because I need days to access my smartphones -that are for me normal computers- the way I want: with ssh, sqlite, python, strace ....
I have a blackbox I should trust based on individual's works that have all the incentive to betray me when the stake will be high enough, and I cannot check anything. I hate it: I am a control freak, not an hipster who likes to show off with his costly gadgets. I am utterly disappointed by android and apple all alike.
I could make wonderful application if I had not the stupid barrier of using their cumbersome SDK and frameworks. It is "an expert" realm, where the only expertise lies in the art of doing a simple thing (development) quite more complex than needed.
I hate smartphones.
I could not buy a normal phone that does only phone and whose battery can last a month. I don't need a computer that I cannot use.