database programming fields cursor fetchone(return fields[ if fields is not none else none the get_director_id(function returns the id of the given director or none if there is no such director in the database we use the fetchone(method because there is either zero or one matching record (we know that there are no duplicate directors because the directors table' name field has unique constraintand in any case we always check for the existence of director before adding new one the fetch methods always return sequence of fields (or none if there are no more records)even ifas herewe have asked to retrieve only single field def edit_dvd(db)titleidentity find_dvd(db"edit"if title is nonereturn title console get_string("title""title"titleif not titlereturn cursor db cursor(cursor execute("select dvds yeardvds durationdirectors name "from dvdsdirectors "where dvds director_id directors id and "dvds id=:id"dict(id=identity)yeardurationdirector cursor fetchone(director console get_string("director""director"directorif not directorreturn year console get_integer("year""year"year datetime date today(yearduration console get_integer("duration (minutes)""minutes"durationminimum= maximum= * director_id get_and_set_director(dbdirectorcursor execute("update dvds set title=:titleyear=:year"duration=:durationdirector_id=:director_id "where id=:identity"locals()db commit(to edit dvd record we must first find the record the user wants to work on if record is found we begin by giving the user the opportunity to change the title then we retrieve the other fields so that we can provide the existing values as defaults to minimize what the user must type since they can just press enter to accept default here we have used named placeholders (of the form :name)and must therefore provide the corresponding values using mapping for the select statement we have used freshly created dictionaryand for the update statement we have used the dictionary returned by locals(