Revert "Merge pull request #374 from LipuFei/fix-db-refactory"

This reverts commit a849a44cb2ac36417350774037982e46431aed65, reversing
changes made to 9ff956dfadcfdd6c1714b90a1ef3394d002a6b85.