Update database instead of insert

Insert would return an error if a key already existed, whereas our
desired behaviour is an update.