return rowdicts if __name__ ='__main__'self test import sqlite conn sqlite connect('dbase 'cursor conn cursor(query 'select namepay from people where pay ?lowpay makedicts(cursorquery[ ]for rec in lowpayprint(recas usualwe can run this file from the system command line as script to invoke its self-test code\pp \dbase\sqlmakedicts py {'pay' 'name''ann'{'pay' 'name''kim'or we can import it as module and call its function from another contextlike the interactive prompt because it is moduleit has become reusable database tool\pp \dbase\sqlpython from makedicts import makedicts from sqlite import connect conn connect('dbase 'curs conn cursor(curs execute('select from people'curs fetchall([('sue''mus' )('ann''mus' )('kim''adm' )rows makedicts(curs"select name from people where job 'mus'"rows [{'name''sue'}{'name''ann'}our utility handles arbitrarily complex queries--they are simply passed through the db api to the database server or library the order by clause here sorts the result on the name fieldquery 'select namepay from people where job order by namemusicians makedicts(cursquery['mus']for row in musiciansprint(row{'pay' 'name''ann'{'pay' 'name''sue'tying the pieces together so farwe've learned how to make databases and tablesinsert records into tablesquery table contentsand extract column names for referenceand to show how these techniques are combinedexample - collects them into single script databases and persistence