Move db generation functions to separate class