added insert and update function for DatabaseGateway.