partial debugging of new db.py for postgres migration