revise lookup to use SQLAlchemy