Fully working conversion of tv.py to peewee based db access.