Initial DB diagnosis code

It will need some minor cleanup