Update default.py

Reorganize slightly so that there is only one commit to db for the entire loop.