Basically this was the key; importing db into potsfyi and using db.init_app(app)