if '-in cmdargsformat true cmdargs remove('-'if cmdargsdbname cmdargs pop( if cmdargstable cmdargs[ format if '-in cmdline args dbname if other cmdline arg from loaddb import login conncurs login(dbnamedumpdb(curstableformatwhile we're at itlet' code some utility scripts to initialize and erase the databaseso we do not have to type these by hand at the interactive prompt again every time we want to start from scratch example - completely deletes and re-creates the databaseto reset it to an initial state (we did this manually at the start of the tutorialexample - pp \dbase\sql\makedb py ""physically delete and re-create database files usagemakedb py dbnametablename""import sys if input('are you sure?'lower(not in (' ''yes')sys exit(dbname (len(sys argv and sys argv[ ]or 'dbase table (len(sys argv and sys argv[ ]or 'peoplefrom loaddb import login conncurs login(dbnametrycurs execute('drop table tableexceptprint('database table did not exist'command 'create table % (name char( )job char( )pay int( ))table curs execute(commandconn commit(commit may be optional here print('made'dbnametablenextthe clear script in example - deletes all rows in the tableinstead of dropping and re-creating them entirely for testing purposeseither approach is sufficient minor caveatthe rowcount attribute doesn' always reflect the number of rows deleted in sqlitesee its library manual entry for details example - pp \dbase\sql\cleardb py ""delete all rows in tablebut don' drop the table or database it is in usagecleardb py dbnametablename"" databases and persistence