implemented insert and update for MySQL