The method to actually write to the database