Almost finished fleshing out filldb.sql, python remains untested for all possible cases.