automatic pull and write mysql