Thanks for the code example, it was instructive comparing it to the 'official' technique:
Code:
from calibre.library import db
db = db('Path to calibre library folder').new_api
I'm learning python as I read calibre's source, so I'm having some fun. On the other hand, I'm well versed in using sqlite from clojure, so that might actually be the safer option.