Move db management into sqlite module