Db abstraction, providing access and search. Currently mostly unoptimized, contribs here would be appreciated