Database wrapper

@cmbirk Ready for review.  Thanks! :)

@waldoj Feel free to have a look and comment!  :)