Only do mysql commit at the end