one of the nice things about using python in the database domain is that you can combine the power of the sql query language with the power of the python generalpurpose programming language they naturally complement each other loading with sql and python supposefor examplethat you want to load database table from flat filewhere each line in the file represents database rowwith individual field values separated by commas examples - and - list two such datafiles we're going to be using here example - pp \dbase\sql\data txt bob,devel, sue,music, ann,devel, tim,admin, kim,devel, example - pp \dbase\sql\data txt bob,developer, sue,music, ann,manager, nowsome database systems like mysql have handy sql statement for loading such table quickly its load data statement parses and loads data from text filelocated on either the client or the server machine in the followingthe first command deletes all records in the tableand we're using the fact that python automatically concatenates adjacent string literals to split the sql statement over multiple linesusing mysql (currently available for python onlylog into mysql first curs execute('delete from people'all records curs execute"load data local infile 'data txt"into table people fields terminated by ','"curs execute('select from people'for row in curs fetchall()print(row('bob''devel' ('sue''music' long integers ('ann''devel' ('tim''admin' ('kim''devel' lconn commit(this works as expected but what if you must use system like the sqlite database used in this bookwhich lacks this specific sql statementorperhaps you just need to do something more custom than this mysql statement allows not to worry-- databases and persistence