curs execute('delete from people where pay >?',( ,)curs execute('select from people'curs fetchall([('sue''mus' )('ann''mus' )('kim''adm' )conn commit(finallyremember to commit your changes to the database before exiting pythonassuming you wish to keep them without commita connection rollback or close callas well as the connection' __del__ deletion methodwill back out uncommitted changes connection objects are automatically closed if they are still open when they are garbage collectedwhich in turn triggers __del__ and rollbackgarbage collection happens automatically on program exitif not sooner building record dictionaries now that we've seen the basics in actionlet' move on and apply them to few larger tasks the sql api defines query results to be sequences of sequences one of the more common features that people seem to miss from the api is the ability to get records back as something more structured-- dictionary or class instancefor examplewith keys or attributes giving column names the orms we'll meet at the end of this map to class instancesbut because this is pythonit' easy to code this kind of transformation in other ways moreoverthe api already gives us the tools we need using table descriptions for exampleafter query execute callthe db api specifies that the cursor' description attribute gives the names and (for some databasestypes of the columns in the result table to see howlet' continue with the database in the state in which we left it in the prior sectioncurs execute('select from people'curs description (('name'nonenonenonenonenonenone)('job'nonenonenonenonenonenone)('pay'nonenonenonenonenonenone)curs fetchall([('sue''mus' )('ann''mus' )('kim''adm' )formallythe description is sequence of column-description sequenceseach of the following form see the db api for more on the meaning of the type code slot--it maps to objects at the top level of the database interface modulebut the sqlite module implements only the name component(nametype_codedisplay_sizeinternal_sizeprecisionscalenull_oknowwe can use this metadata anytime we want to label the columns--for instancein formatted records display (be sure to regenerate query result firstsince the prior result has been fetched)sql database interfaces