finish moving database population functions to io.py

I did this in two waves because I wanted to make sure it still worked in
the middle