set expire_on_commit to true to avoid sqlalchem.DetachedInstanceError