Changed Statistics Engine to use sqlalchemy api rather than explicit sql