AddressBook2W3

The Mac AddressBook on your web site. Download now.
AddressBook2W3 is the result of the video card on my MacBook Pro dying and I ended up with no access to any of my Contacts info that had been stored in the Mac AddressBook. Luckily Time Machine had my data file in its archive, but without a Mac near by I wasn’t able to read the AddressBook.data file.
Searching for some utilities that would read that file without a Mac AddressBook client, I came across Mark Liyanage’s blog post Reading Out Address Book Data From a Widget.
I’ve always wanted to have HTTP and command line access to my address book, so I took took advantage of my separation from the Mac to create AddressBook2W3, a simple PHP script that will both render the AddressBook in X/HTML and on the command line.
The Mac OS/X Leopard (10.5.x) the SQLite AddressBook data file can be found at:
~/Library/Application Support/AddressBook/AddressBook-v22.abcddb
The first thing I did was convert the SQLite3 database to SQLite 2 so I could use the default version of Apache/PHP5 I had installed on my Ubuntu 8.04 Linux machine (it also happens to match the configuration on my MacBook Pro).
$ sqlite3 ~/Library/Application\ Support/AddressBook/AddressBook-v22.abcddb .dump > AddressBook.dump
$ cat AddressBook.dump | grep -v 'INSERT INTO "Z_METADATA"' | sqlite addressbook.db
The dump file ‘AddressBook.dump’ is SQLite SQL and human readable. I built the application by reading the SQL and made my first few calls by simply reading the phone numbers directly from this file.
I had a couple meta data blobs that didn’t import directly and since I didn’t and was in a rush I simply removed the blob insert statements during the import via a simple grep command.
Now that I have an SQLite 2 database, I copied that file along with the three AddressBook2W3 files (index.php; company.gif and person.gif) to a new sub-directory on my web root.
Browsing to the web directory renders an Address List like the following:

The Address detail can be seen at the top of this page. The command line program is invoked as:
php index.php search apple
And looks like the following:

Note: If you need SQLite 2 or an Apache/PHP configuration for OS/X, I recommend you take a look at The MacPorts Project.