we could use fresh dictionary for bothin which case for the update we would pass dict(title=titleyear=yearduration=durationdirector_id=director_idid=identity)instead of locals(once we have all the fields and the user has entered any changes they wantwe retrieve the corresponding director id (inserting new director record if necessary)and then update the database with the new data we have taken the simplistic approach of updating all the record' fields rather than only those which have actually been changed when we used dbm file the dvd title was used as the keyso if the title changedwe created new key-value item and deleted the original but here every dvd record has unique id which is set when the record is first insertedso we are free to change the value of any other field with no further work necessary def find_dvd(dbmessage)message "(start oftitle to message cursor db cursor(while truestart console get_string(message"title"if not startreturn (nonenonecursor execute("select titleid from dvds "where title like order by title"(start "%",)records cursor fetchall(if len(records= print("there are no dvds starting with"startcontinue elif len(records= return records[ elif len(recordsdisplay_limitprint("too many dvds ({ }start with { }try entering "more of the titleformat(len(records)start)continue elsefor irecord in enumerate(records)print("{ }{ }format( record[ ])which console get_integer("number (or to cancel)""number"minimum= maximum=len(records)return records[which if which ! else (nonenonethis function performs the same service as the find_dvd(function in the dvdsdbm py programand returns -tuple (titledvd id)or (nonenonedepending on whether record was found instead of iterating over all the data we have used the sql wildcard operator (%)so only the relevant records are retrieved