Updated cso-history endpoint to use declarative SQLAlchemy