Move more db management into sqlite module, Create same for MySQL.