Database connector

The database connector currently compiles (two hours of dependency
hunting later). Tests forthcoming.