move database specific code to library file of appropriate name.