Next, let’s check our work with the dump utility (use a - argument to force a formatted
display):
...\PP4E\Dbase\Sql> dumpdb.py testdb
('bob', 'developer', 80000)
('sue', 'music', 90000)
('ann', 'manager', 80000)
...\PP4E\Dbase\Sql> dumpdb.py testdb -
3 records
----------------------------------------
pay => 80000
job => developer
name => bob
----------------------------------------
pay => 90000
job => music
name => sue
----------------------------------------
pay => 80000
job => manager
name => ann
----------------------------------------
The dump script is an exhaustive display; to be more specific about which records to
view, use the query script and pass in a query string on the command line (the command
lines are split here to fit in this book):
...\PP4E\Dbase\Sql> querydb.py testdb
"select name, job from people where pay = 80000"
2 records
----------------------------------------
job => developer
name => bob
----------------------------------------
job => manager
name => ann
----------------------------------------
...\PP4E\Dbase\Sql> querydb.py testdb
"select * from people where name = 'sue'"
1 records
----------------------------------------
pay => 90000
job => music
name => sue
----------------------------------------
Now, let’s erase and start again with a new data set file. The clear script erases all records
but doesn’t reinitialize the database completely:
...\PP4E\Dbase\Sql> cleardb.py testdb
Are you sure?y
...\PP4E\Dbase\Sql> dumpdb.py testdb -
0 records
1352 | Chapter 17: Databases and Persistence